Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!umich!yale!mintaka!bloom-beacon!bu.edu!bu-cs!xylogics!world!bzs From: bzs@world.std.com (Barry Shein) Newsgroups: alt.religion.computers Subject: Re: Shoulds arrays start at zero or one? Message-ID: <1990Jan17.044003.2039@world.std.com> Date: 17 Jan 90 04:40:03 GMT References: <252@usblues.UUCP> <1990Jan16.173034.25686@murdoch.acc.Virginia.EDU> <4822@crdgw1.crd.ge.com> Distribution: na Organization: The World @ Software Tool & Die Lines: 55 In-Reply-To: shane@underdog.crd.ge.com's message of 16 Jan 90 21:24:44 GMT From: shane@underdog.crd.ge.com (Randall H. Shane) >Of course, the performance implications of 'stoopid' compilers are >enormous, and often not told to USENET posters. Stupid compilers >exist for most, if not all languages, and the mere existence of stupid >compilers is hardly a reason to slam a computer language. Intelligent >Pascal compilers, while enforcing the semantics of var and non-var >parameters in the program text, for efficiency's sake pass large structures >such as arrays by reference in both cases. This efficient implementation >is not a contradiction of the programmer's intent, let us note.... Over the past decade or so, whenever I get into an argument about how dumb Pascal is, the Pascal proponent always informs me of wonderous Pascal compilers which fix the complaint at hand. Everyone knows that Pascal has no initialization syntax. So one is told to just put a lot of assignments in the mainline which has roughly the same effect (roughly because the errors can be different, but we'll leave that be.) If I point out that this can exact a heavy start-up cost (particularly if setting array elements) on every run of the program I am often told: Well, that's just because of stupid compilers, good Pascal compilers recognize these and turn them into the same as C (load-time initialization.) Ok, makes sense, I know compiler internals well enough to know that's possible or at least plausible. One day, after such an argument, I wrote a simple piece of Pascal code and compiled it on several compilers: Unix/Pascal, VMS/Pascal, IBM370/Pascal/VS, (some other 370 Pascal we had), Greenhill, a few others. Examining the generated code in each case revealed that not one of them performed this "optimization", they all did some form of load and store as regular code in the routine. When confronted with this the Pascal proponent could not name a compiler known to perform the claimed optimization and admitted that every one he had used was in my test suite. Swell. I've seen similar claims for Pascal compilers, including a claim that one should handle variable length strings (something Pascal is incapable of) by putting them into single-character linked-lists and the compiler will fix that to be a lot like C (no joke.) So, I ask, exactly which Pascal compiler performs the optimization of hunting down call by value parameters and changing them to call by reference, specifically. If you can produce some sample generated code all the better. Thank you. -- -Barry Shein Software Tool & Die, Purveyors to the Trade | bzs@world.std.com 1330 Beacon St, Brookline, MA 02146, (617) 739-0202 | {xylogics,uunet}world!bzs