[E-Lang] the return of `return'
zooko@zooko.com
zooko@zooko.com
Mon, 18 Jun 2001 12:17:11 -0700
Thanks, Darius, for this informative article!
My responses below are all questions and assertions about factual matters, not
about values.
Darius Bacon <darius@accesscom.com> wrote:
>
> so the `return' doesn't return from the function a beginner would
> expect. This could be fixed by giving `for' an uglier expansion. Or,
> we could change the definition syntax to explicitly name the return
> escaper, like
>
> def foo(collection) return {
> for key => value in collection { ... return(x) ... }
> }
...
> This preserves the security properties of Zooko's idea, at the cost of
> an unfamiliar definition syntax. But familiarity was our main goal.
Couldn't it just be the innermost function that was declared with `def'?
> Third, if `return' is required then common E patterns are just too
> painful:
>
> def fooMaker(x) {
> return(def foo {
> to blat() { ... }
> })
> }
>
> Some ideas on this one:
>
> 1. Make `return' optional. Then the :retAny guard would be no help.
One of the reasons that I like the `:ret' guards is that they are optional.
The example you give above could just be:
def fooMaker(x) :expAny {
...
or better yet:
def fooMaker(x) :expSomeUsefulGuardHere {
...
> With all these unappealing alternatives, I have to wonder how shocking
> E's expression style really is for our users. There are at least two
> popular expression-style languages: Perl and the sh family.
... and both have an optional `return' keyword which immediately exits from the
lexically innermost function with the optionally non-parenthesized accompanying
expression as the return value.
Regards,
Zooko