Martin C. Martin | 22 Jun 02:12

Re: [groovy-dev] advice needed

See:

http://jira.codehaus.org/browse/GROOVY-715

Best,
Martin

Alex Tkachman wrote:
> Hi!
> 
> I've implemented default return from if/else
> 
> def f () {
>    if (true)
>       1
> }
> 
> assertEquals 1, f()
> 
> It is not commited yet but works nicely including nested ifs, closures etc.
> 
> Now I try to do the same for switch (which is relatively easy) and
> try/catch/finally (which is complicated), obviously that unfortunately
> there is no intuitively clear meaning of such return for loops.
> 
> The main problem with try/catch/finally is how should it work. The
> question is what should be returned in case of last statement
> try {
>   ......
>   1
> }
> catch (Throwable t) {
>   "exception"
> }
> finally {
>   0
> }
> 
> My idea is that it should return either 1 or null (if exception
> happen). Saying strongly - we add syntetic returns inside try block
> but not inside catch or finally blocks.
> 
> Does it make sense?
> Could somebody suggest more reasonable behavior?
> 
> Best regards
> Alex
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane