Talk:Block
From Nemerle Homepage
I suppose this is yet another way to imitate imperative processing? I mean - is there anything you could not do by writing a simple function? --kali 20:43, 12 May 2005 (CEST)
Actually it is just another way to facilitate imperative programming. Functional programming is not the best tool to solve all tasks in the world. There are problem domains where it shines and there are problems domains where other programming paradigms shine. This is why Nemerle allows object oriented, imperative and meta programming -- because it is a general purpose language.
Now once we allowed loops, they should be usable, not just a poor man's substitute. This block thingy makes them more usable than they are in other languages. I consider it a good thing.
And yes, all that can be handled with a simple recursive functions, but
- imitating foreach with a function is some work with the enumerators
- loops are in most simple cases just more readable
--Malekith 14:56, 14 May 2005 (CEST)
Well, nothing I couldn't agree with. Consider me convinced ;)
--kali 17:52, 14 May 2005 (CEST)
looks too much like named-let
Just a minor reservation: foo (3) looks a lot like recusrively entering the foo block.
To me, at least, this syntax does suggest re-entrance, not existing from the block.
How about this? would this clash with the namespace mechanism?
foo: { when (some_cond) foo.return(3); qux(); 42 }
Probably using
foo = 3 could be a little bit cleaner. But I think that after getting acustomed with this
syntax it is not a real problem.
continue statement in C
I just stumbled upon this site and thought it looked interesting... however, I must point out that the continue statement in C does not work as described... it doesn't exit from the enclosing loop, it merely starts the next iteration. So the code:
while (y > 0) { when (y % 33 == 0) continue; when (some_cond) break; when (some_other_cond) return y; }
would be syntactic shorthand for:
break: { while (y > 0) { continue: { when (y % 33 == 0) continue (); when (some_cond) break (); when (some_other_cond) return y; } } }
The call to continue () exits the continue: block, starting the next iteration to the loop but not (necessarily) exiting the loop.
-User:Giles 3 Jan 2007
Yes, this page was wrong, the compiler did the right thing though. Thanks!
--Malekith 10:03, 4 January 2007 (CET)