Expr based return
alexlamsl
7 Feb 2009
+1 Should be pretty natural for people to pick this feature up.
jodastephen
7 Feb 2009
I'm good with this in closures, and I think it'll be OK in methods too. It must be just one expression though - multiple expressions need a return.
andy
7 Feb 2009
Yep I like that.
f00biebletch
11 Feb 2009
I'd be cool with omitting return only on closures, but I'm happy with this as well. Thanks for making it happen.
tompalmer
11 Feb 2009
I think I lean towards closures only, but I can't say I have a good reason. Just gut. Maybe better to be consistent in both cases, as you've proposed. (And I'm still looking forward to seeing simply slots.map(Str[,]) |s| { s.name } work, too, or at least where the type inference is easy enough.)
brian
13 Feb 2009
This change set has been pushed to hg for the next build.
brian
7 Feb 2009
We've talked about this before, but I want to nail down the specifics before I implement.
There is a proposal which seems generally favorable to everybody to allow you to omit the
returnkeyword for simple closures and maybe methods. It is potentially the first step to expr based statements, although that seems unlikely for 1.0.Here is what I propose specifically: you may omit the
returnkeyword in a method or closure if the body consists of exactly one statement:// method example Str fullName() { "$firstName $lastName" } // closure example slots.map(Str[,]) |Slot s->Str| { s.name }If you have more than one statement, then you must continue to use an explicit
returnstatement - although in that case, I think the extra syntax aids readability versus creating noise in the simple cases above.