I have added blocks to the language:
for var i in 0 upto 3 begin
var x = 1;
println$ x + i;
end
for i in 0 upto 3 begin
var x = 1;
println$ x + i;
end
This is more or less the same as
do { ... }; done
You can write:
if cond begin .. elif .. do .. else .. end
Note the elif's still require a do.
Blocks being just { .. }; are like
call (proc () { .. }) ();
so the important thing to note is that stuff declared in a block
is hidden. You should note some important caveats:
(1) You cannot jump to a label in a block -- because it is hidden.
(2) if you "return" in a block it just returns from the block NOT
the enclosing function. you can solve this with "return from":
proc a () {
begin
println$ "One";
return from a;
end
println$ "Two";
}
Break, continue, redo are not impacted because Felix *only* supports
the labelled form of these and they're all equivalent to gotos. In a block
these just become non-local gotos.
(3) In the low level for loops. the control variables is NOT hidden You can
use instead:
begin for .. do .. done end
to achieve that but of course it's messy :)
--
john skaller
[email protected]
http://felix-lang.org
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language