[prev in list] [next in list] [prev in thread] [next in thread]
List: groovy-dev
Subject: Re: [groovy-dev] FYI - Strange return behavior (fwd)
From: cpoirier () dreaming ! org
Date: 2004-06-28 8:00:51
Message-ID: 1088409651.40dfd033cc91e () www ! dreaming ! org
[Download RAW message or body]
Hi John,
Quoting John Wilson <tug@wilson.co.uk>:
>
> On 25 Jun 2004, at 00:28, Chris Poirier wrote:
> > Hmmm, yes, what you are talking about /are/ anonymous functions, which
> > is what a closure becomes if it is stripped of its context. And that
> > certainly is a handy feature, I'll admit. :-)
> >
> > However, the behaviour of return in the /closure/ case (ie. when the
> > block is used within the scope of its context) should be to adhere to
> > the closure's context. This is, I believe, the expected behaviour --
> > it
> > certainly is for me.
> >
> > In the case of demoting the closure to an anonymous function, "return"
> > should be demoted to the equivalent of "break". Also, I believe, what
> > is expected.
> >
>
> I don't really see how this can be done in practice.
I think we need lambda() or something similar to convert a closure to an
anonymous function, and then to do away with the idea of a closure that isn't
just a block. The lambda() code wraps the closure in a context that handles
calling it and correctly converts the closure exit routes. The problems you
are talking about, I think, are due to the fact that Groovy isn't
distinguishing between a closure and an anonymous function.
That said, I'm getting pretty sleepy, so I could be missing something obvious.
:-)
Later,
Chris.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic