Re: $ shorthand side-effect (was Digest for EUforum at topica.com, issue 6333)
- Posted by Chris Bensler <bensler at nt.net> Jan 10, 2007
- 509 views
CChris wrote: > > Chris Bensler wrote: > > > > It's more prevalent because of how you changed the order of evaluation. > > IMO, the previous behaviour was more logical. That is all. It now requires > > more > > thought to determine if there will be side-effects. > > > > I wouldn't say it was logical really. Please read > <a > href="http://www.listfilter.com/cgi-bin/esearch.exu?thread=1&fromMonth=B&fromYear=7&toMonth=1&toYear=8&keywords=">http://www.listfilter.com/cgi-bin/esearch.exu?thread=1&fromMonth=B&fromYear=7&toMonth=1&toYear=8&keywords=</a>"Bug+or+inconsistency+in+evaluation+rules+regarding+edge+effects" > > I didn't test that code under 3.0, but can't see why it's strange behaviour > > could have been modified. *more* logical. It's still an undefined behaviour. Here is a sample of code that I think demonstrates why the code you posted in the link works the way it does. l=2 ?(l+0+f(3)+f(1)+2*l) --result: 8=2+0+2+2+2*1 The reason that the other statements are unexepected results is because in the first part of the expression, l+f() share the same operator. l is read first but it's modified in f() before the term is actually evaluated. By adding the 0 operand, I decoupled l+f(), so l is properly evaluated first before f() is ever encountered. (The behaviour is the same using 3.0) The difference from 2.4 and 2.5 is how subscripting is evaluated. Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria