roxen.lists.pike.general

Subject Author Date
Re: Pike & Python Paul Miller <listmail[at]voltar-confed[dot]org> 12-12-2008
On Fri, Dec 12, 2008 at 12:13:04AM +0100, Martin Stjernholm wrote:
> > Oh, cool.  Not nearly as intuitive for the casual reader, though.
> 
> I agree. The reason a < b < c doesn't work is that it isn't compatible
> (it gets parsed like (a < b) < c). The places where one wants
> (a < b) < c and has decided to leave out the parens ought to be
> extremely few though, so if we introduce a warning for that then
> someday down the road I think we could change it.
> 
> One tricky thing though is that we'd need a new calling convention for
> cases like a < b <= c; neither `< (a, b, c), `<= (a, b, c), nor
> `<= (`< (a, b), c) would work. Hmm, the compiler would probably
> rewrite it to (`< (a, bv) && `<= (bv, c)), where bv is the value from
> b (since b should only be evaluated once).


It seems blisteringly obvious to me that the lexer/parser could be
taught to re-write "a<b<c" as "a<b and b<c" before the parse.
Then it would work as expected, would be readable, and wouldn't
require a new calling convention at all.

Is that just crazy talk?  Is that a possible option?

-- 
If riding in an airplane is flying, then riding in a boat is swimming.
107 jumps, 43.5 minutes of freefall, 83.4 freefall miles.