Block Lambdas: break and continue
esdiscuss at grant.x43.net
Fri Jan 13 19:29:48 PST 2012
Block lambdas have been a hot topic, recently, but there's a point of
significant divergence between Ruby (which appears to be the inspiration)
and the proposed solution, in the handling of continue (called 'next', in
Ruby) and 'break'.
To whit: In Ruby, 'next' will end the current run (iteration) of the block,
and 'break' will (somehow) terminate the method lexically connected with
the block. It can be claimed that this is more intuitive than the current
proposal, which aims to make 'break' and 'continue' propagate through block
lambdas in the same way 'return' would.
Ruby does also support syntactic loops and the same keywords therein and so
directly violates Tennent's Correspondence Principle, even though such has
been touted as a core reason for the construct. Instead, I believe it
reasonable to invoke intuition in this matter. It is intuitive for 'return'
to return a value from the lexically enclosing method and it is intuitive
for 'continue' to commence the next iteration of the current loop, however
that loop is constructed.
Note that the label-based break/continue could still have the desired
effect, if the proposal was updated to be more like Ruby's blocks.
I don't have a strong opinion on the subject, but I hadn't noticed the
above being discussed, elsewhere, and thought it worth raising. If there is
a better place for me to raise this, please let me know where and accept my
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss