Gafter's block expression proposal.

113 views
Skip to first unread message

Reinier Zwitserloot

unread,
Feb 24, 2009, 3:22:19 PM2/24/09
to The Java Posse
Via twitter:

http://docs.google.com/Doc?id=ddb3zt39_77cgxvktgs&hl=en

I like it, mostly. Less magic as with the BGGA proposal (where the
final semi-colon or lack thereof decides between a void or a non-void
return type), and far less impact.

Incidentally, my forthcoming unifiying closure proposal (or really any
other closure proposal) could use familiarity in the community with
the concept.

Viktor Klang

unread,
Feb 24, 2009, 4:03:02 PM2/24/09
to java...@googlegroups.com
Looks Scala-esque (in the positive sense)

So basically the code block is executed once and the very last expression will be "returned"?
--
Viktor Klang
Senior Systems Analyst

Reinier Zwitserloot

unread,
Feb 25, 2009, 12:00:31 PM2/25/09
to The Java Posse
Yes, and that also decides the type. It HAS to be an expression, there
is no way to make the expression block be of the void type, and
therefore there is no semi-colon magic as in the BGGA proposal. There
MUST be an expression as the last statement, with an actual type. That
will also be the type of the expression block.

That makes this proposal a lot simpler than the BGGA blocks.

On Feb 24, 10:03 pm, Viktor Klang <viktor.kl...@gmail.com> wrote:
> Looks Scala-esque (in the positive sense)
>
> So basically the code block is executed once and the very last expression
> will be "returned"?
>

liang guo

unread,
Jan 4, 2013, 11:16:08 AM1/4/13
to java...@googlegroups.com
Hello,
That's a good idea. Recently I'm doing a project, adding Python List feature to javac, I found I need this block expression very much. Do you know any one implemented this? Or any further information? I may have to implement it myself, if not. Thanks very much.


在 2009年2月24日星期二UTC下午8时22分19秒,Reinier Zwitserloot写道:

morten hattesen

unread,
Jan 5, 2013, 8:22:57 AM1/5/13
to java...@googlegroups.com
I like the simplicity and elegance of this proposal, and the fact that it follows the Principle of Least Astonishment.

Joseph Darcy

unread,
Jan 5, 2013, 3:11:53 PM1/5/13
to java...@googlegroups.com
On Fri, Jan 4, 2013 at 8:16 AM, liang guo <supe...@gmail.com> wrote:
> Hello,
> That's a good idea. Recently I'm doing a project, adding Python List feature
> to javac, I found I need this block expression very much. Do you know any
> one implemented this? Or any further information? I may have to implement it
> myself, if not. Thanks very much.

Neal's proposal was sent in as part of JDK 7's Project Coin call for
proposals effort:

http://mail.openjdk.java.net/pipermail/coin-dev/2009-February/000002.html
https://blogs.oracle.com/darcy/entry/project_coin_week_1_update

However, the proposal was not selected as one of the ones to include
as part of Project Coin:



>
>
> 在 2009年2月24日星期二UTC下午8时22分19秒,Reinier Zwitserloot写道:
>>
>> Via twitter:
>>
>> http://docs.google.com/Doc?id=ddb3zt39_77cgxvktgs&hl=en
>>
>> I like it, mostly. Less magic as with the BGGA proposal (where the
>> final semi-colon or lack thereof decides between a void or a non-void
>> return type), and far less impact.
>>
>> Incidentally, my forthcoming unifiying closure proposal (or really any
>> other closure proposal) could use familiarity in the community with
>> the concept.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Java Posse" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/javaposse/-/ICtOiaFbD4gJ.
> To post to this group, send email to java...@googlegroups.com.
> To unsubscribe from this group, send email to
> javaposse+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.

Joseph Darcy

unread,
Jan 5, 2013, 3:12:56 PM1/5/13
to java...@googlegroups.com
On Sat, Jan 5, 2013 at 12:11 PM, Joseph Darcy <jdd...@gmail.com> wrote:
> On Fri, Jan 4, 2013 at 8:16 AM, liang guo <supe...@gmail.com> wrote:
>> Hello,
>> That's a good idea. Recently I'm doing a project, adding Python List feature
>> to javac, I found I need this block expression very much. Do you know any
>> one implemented this? Or any further information? I may have to implement it
>> myself, if not. Thanks very much.
>
> Neal's proposal was sent in as part of JDK 7's Project Coin call for
> proposals effort:
>
> http://mail.openjdk.java.net/pipermail/coin-dev/2009-February/000002.html
> https://blogs.oracle.com/darcy/entry/project_coin_week_1_update
>
> However, the proposal was not selected as one of the ones to include
> as part of Project Coin:

Adding in the URLs I meant to include the first time,

http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000068.html
https://blogs.oracle.com/darcy/entry/project_coin_consideration_round_2

-Joe

Reinier Zwitserloot

unread,
Jan 18, 2013, 9:54:59 AM1/18/13
to java...@googlegroups.com
Wait for java 8. It'll have something like it (google for 'state lambda goetz' for explanations of syntax and how it'll work).

Ricky Clarkson

unread,
Jan 18, 2013, 9:59:55 AM1/18/13
to javaposse
I'm not sure the lambda syntax will provide anything useful for that.  Can you be more specific, Reinier, in case I've missed something?

Incidentally, valid since Java 1.1:

int x = new Object() { int foo() { int result = 5; result++; result *= 10; return result; } }.foo();




--
You received this message because you are subscribed to the Google Groups "Java Posse" group.
To view this discussion on the web visit https://groups.google.com/d/msg/javaposse/-/0W8pcAUNT4gJ.
Reply all
Reply to author
Forward
0 new messages