From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/06 Message-ID: <619p6o$6fi$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 278132336 References: <3431A2DB.4273@EasyInternet.net> <60ui2q$33a$1@cdn-news.telecom.com.au> <60ujk7$i58$1@lyra.csx.cam.ac.uk> <3432F896.7FD2@HousemarqueREM.fi> <3433AAC0.10C4@NOSPAMarm.com> <611r14$4i6$1@clarion.carno.net.au> <6131q6$8o1$1@dartvax.dartmouth.edu> Organization: Comp Sci, RMIT University, Melbourne, Australia. NNTP-Posting-User: ok Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec mac@coos.dartmouth.edu (Alex Colvin) writes: >>Hmmm... I think Pascal had the right approach when it came to reference >>parameters: the effects of passing the same variable into a function >>via more than one VAR parameter were "undefined", which left the >>language implementor more scope for optimization. >Last time I mentioned this, I was informed that this restrictition had >been dropped. ISO 10206:1990, Extended Pascal has four kinds of parameters: a: integer; pass by copy-in, modifiable var b: integer; pass by reference, modifiable protected c: integer; pass by copy-in, not modifiable protected var d: integer; pass by reference, not modifiable The confusing thing (Note 2, p55) is that a protected variable parameter (protected var) may not be changed, but it may change. This is the only mention of 'aliasing' that I can find in that standard. Of course this kind of thing is very upsetting to optimisers. It means that in the sequence of statements x := d; x := d; where contains no other assignments to x, if contains any assignments to non-local integer variables or procedure calls, x will have to be reloaded, even tough _this_ procedure isn't allowed to modify d directly. This is even more upsetting to human reasoning than to optimisers. >Support for aliasing may be a good thing. Undefining the effect of >aliasing looks likely to lead to seriously obscure bugs, unless you can >check this behavior at compile time. Consider this: C If this were F90, I'd have INTENT OUT stated explicitly SUBROUTINE BREAK(X, Y) REAL X, Y X = 1.0 Y = 2.0 END PROGRAM MAIN REAL A(10) INTEGER I, J READ * I, J CALL BREAK(A(I), A(J)) PRINT *, A(I), A(J) END What is the output of this program? How is the compiler to check at compile time that I.NE.J? It is important to distinguish between case where you WANT to support aliasing (which is the expensive option) and cases where you DON'T (which is the high performance option). Ada 95 did the right thing here, requiring you to explicitly declare any potentially aliased variables. Aliasing is very confusing for people to deal with. Of course, as soon as you have objects as in Smalltalk or Common Lisp or Java, you have precisely the same kind of problem when the same object reference can be passed (the _reference_ is passed by copy-in) to a procedure. -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.