Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!emory!att!pacbell.com!ucsd!nosc!cod!sampson From: sampson@cod.NOSC.MIL (Charles H. Sampson) Newsgroups: comp.sys.mac.programmer Subject: Re: Pascal deficiency? Message-ID: <2636@cod.NOSC.MIL> Date: 7 Jan 91 18:12:39 GMT References: <33176.27759EC3@stjhmc.fidonet.org> Reply-To: sampson@cod.nosc.mil.UUCP (Charles H. Sampson) Organization: Computer Sciences Corporation Lines: 22 In article <33176.27759EC3@stjhmc.fidonet.org> Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) writes: >Where Pascal falls down is in address arthmetic: >for i := 1 to rows do > for j := 1 to columns do > thearray[i,j] := something; >will generate a run time multiply to each time through the inner loop to >figure >out the offset from the start of the array. On the Mac you can work around >this by writing something like: ... I've just picked up this thread, so I hope my comment hasn't been made already. The above complaint appears to be against the Pascal language for not doing a good job on array accesses. The fault is not the language, it's the compiler. There is an ancient code optimization technique called strength-reduction that will remove all the multiplies in favor of setting up an initial address outside the loop and then calculating the next address inside the loop by addition, just like the deleted example did. This tech- nique is so old and understood so well that many don't even consider it an optimization any more -- just a standard code-generation technique. As to why your favorite compiler isn't doing it, you'll have to ask the vendor. Charlie