From: Seebs Date: 2009-11-22T17:00:07+09:00 Subject: Re: Order of evaluation and precedence On 2009-11-22, David Masover wrote: > On Saturday 21 November 2009 05:25:07 pm Seebs wrote: >> (In C, I think it's a feature that order of evaluation isn't defined; >> in Ruby, I think it's probably a feature that it is.) > I'm curious why you think each behavior is a feature... > In Ruby, the "feature" would be to make things easier to understand, POLS and > all that. While I don't find left-to-right intuitive here, it's certainly > intuitive that method dispatch is deterministic -- I suspect it's the same > philosophy behind making hashes preserve insertion order in 1.9. Basically, yeah -- I like the idea of having a predictable order for evaluation as much as possible in a high level language. > In C, the only feature I can see is that some optimizations could be made, > right? I'm curious how exactly that would work, in a non-functional language > like C. I'm not doubting it could be, I just don't know how. Basically, compilers can generate all the code they need, then shuffle it around to do things like "keep these three operations together since they will use the same cache line" or "calculate the branch for the ternary operator long enough before taking it for the branch predictor to kick in", stuff like that. For instance, in a lot of implementations, function args might be evaluated left-to-right for most functions, but right-to-left for variadic functions. Weird stuff happens. :) -s -- Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!