J3/97-186r1 Pate 1 of 1 Date: May 15, 1997 To: J3 From: Interval-1 Subject: Named Expressions During a discussion of interval arithmetic, it was observed that a common idiom is: T=a+b ... T2=T+c+d Where the programmer expects that this will be evaluated precisely the same as if written as T2=a+b+c+d ! the corrigenda item that permits (a+b)+c+d isn't a "solution" The point is that ! some (many?) users expect it to be *identical*. This is more of an issue on some ! processors than others. More complicated expressions are, of course, more ! entertaining. For intervals, the issue is that accurate results are arguably ! prohibited. Currently this is not the case because interline optimization is technically prohibited. This is historically not a widely noticed problem since on many processors in many contexts the transformation cannot be detected by effects or means defined by the Standard. However for interval expressions both performance and sharpness are considerably improved with such interline optimizations. Rather than trying to change the standard to either explicitly allow interline optimization in general, or to redefine the current meaning of "=" from assignment to something along the lines of mathematical equality, it is proposed to provide a way to name an expression. Illustrative syntax (1) T .name_for. Expression (2) T === Expression (3) T := Expression (4) T ._ _ _. Expression. Spelling aside, "T" would then act akin to a compiler generated temporary (or a macro, without the issues of extending a statement beyond the processor supported line length). (1) is inconveniently wordy. (4) is ugly (underscore space underscore space underscore space) (3) is unfortunate in that the Algol descended languages use it for assignment, which might be confusing (albeit fitting, since Algol deviated from the original Fortran choice of "=" for assignment ;>). An alternative approach would be to add a new attribute "temporary", no new syntactic element would be needed. However, being "variable-like" probably has a practical difference. Consider: EX 1 A=0 ; B=0 ; T .something. A+B ! or attribute A = 10 ; B=20 ; print *,T What does this print? With named expressions 30. With "attribute" 0? Potential straw votes: (a) work on relaxing the interline optimization prohibition, or "this" (b) attribute or syntax. (c) if syntax option 1,2,3,4 above. (d) should EX 1 produce 0 or 30?