News for hackers. Stuff that matters.
Re:A semantic model for a substantial fragment of C by Johnny_Brahms on Saturday April 01, 2017 @07:51AM (#14011676)
The scheme standard actually bit my sorry behind recently. I was porting a small library between scheme implementations, and my tests were failing.

I had always thought it was evaluated left->right (which it was in the first scheme implementation), but it is in fact standardised as "The order of evaluation is unspecified". The reason I hadn't noticed before was that most my code is rather functional. Now I was reading a char from a file handle, and peeking it as the other argument.

It failed because read-char is destructive (it changes the position of the file pointer), and since the order was the other way around in the scheme I was porting to, all the procedures relying on my "read-until" method started failing left and right.

It just took me ~20 years to figure it out...

Re:A semantic model for a substantial fragment of C by agumonkey on Saturday April 01, 2017 @10:11AM (#14012188)
ouch.
Re:A semantic model for a substantial fragment of C by Johnny_Brahms on Saturday April 01, 2017 @02:19PM (#14013341)
Yup. Did not feel great.

The worst part is that I admitted to writing code that rely on order of evaluation on Hackernews.

To my defense it is _very_ old code that I converted from an even older turbo Pascal program I wrote as a teenager

Re:A semantic model for a substantial fragment of C by Johnny_Brahms on Saturday April 01, 2017 @04:22PM (#14013974)
To clarify: the bug took about 3 minutes to figure out. Learning the evaluation order of procedure arguments is undefined took 20 years though :)
Re:A semantic model for a substantial fragment of C by agumonkey on Saturday April 01, 2017 @06:36PM (#14014554)
And I had no idea it was officially fixed ordered in standard. I've read mentions in papers but I never realized what they meant.
Re:A semantic model for a substantial fragment of C by Johnny_Brahms on Wednesday April 05, 2017 @05:10AM (#14040764)
Well: The thing is that it is _not_ fixed. It is defined as unspecified.
Re:A semantic model for a substantial fragment of C by sigjuice on Saturday April 01, 2017 @10:19AM (#14012221)
Would this be an issue in Common Lisp? I believe CL function arguments are evaluated left-to-right.
Re:A semantic model for a substantial fragment of C by fiddlerwoaroof on Saturday April 01, 2017 @12:40PM (#14012931)
It is undefined in Common Lisp whether or not the car of a form is resolved to a function before or after the other arguments, iirc
Re:A semantic model for a substantial fragment of C by lispm on Saturday April 01, 2017 @12:28PM (#14012871)
That's right. The standard says left to right.

It's not good style to exploit that, but you can.