[e-lang] Anonymous closures and custom control flow in E
Kevin Reid
kpreid at switchb.org
Thu May 26 17:28:25 PDT 2011
On May 26, 2011, at 16:59, Constantine Plotnikov wrote:
> Hello!
>
> I'm writing some presentation that mentions E. Do I understand it correctly that E still does not have a closure syntax that allows creation of custom control flow constructs?
>
> I mean control constructs like "with(resourceOpen()){resoruce->body(resource)}" or "collection.foreach{i-> doSomethidAbout(i)}".
E does have such, as an experimental feature. The pragma name for it is "lambda-args"; there is some description of how it works in the mailing list archives, at least. If you don't find enough information, let me know and I'll try to write it up on the wiki.
The basic syntax is
<expr>(<params...>) [<identifier-or-keyword> <params...> { <body> } ]*
where the square brackets are meta and there are some variations I haven't thoroughly examined myself. The effect of it is to make chained calls to the value of <expr> which pass in the <body>s wrapped in closures.
There are some basic control structures reimplemented in terms of lambda-args in E-on-Java at:
src/esrc/org/erights/e/elang/control/
--
Kevin Reid <http://switchb.org/kpreid/>
More information about the e-lang
mailing list