Re: Euphoria's strengths

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
petelomax said...

I suspect we might want to prohibit var_id on for loop control vars.

Pete

Why? (Just curious.)

Erm, gut feeling, mainly, I suppose. If the compiler is prohibiting "i:=5" then letting the programmer defeat the compiler using var_id() sounds like an accident waiting to happen.
Certainly, in Phix, the end for is optimised to use the register version (if not reused) and clobber the memory copy without even checking it, because right now, it can.
Maybe/Probably the presence of a get_id()/set_var() in the loop body would be enough to ensure the register has been recycled before it gets to the end for.

There is also another matter/warning that I completely missed: type inference.
If the compiler deduces that an atom (eg loop control var, but others too) is, say, an integer, but set_var() sets it to a float, it'll go belly up for sure.
There is some constant/range propagation that I nicked from Eu, which might break, and Phix also has string/sequence and inferred udts to worry about.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu