A syntax option (function types versus arrays)

Howard Lovatt howard.lovatt at gmail.com
Thu Mar 11 22:49:54 PST 2010


If new were used, as suggested, then it would make SAM types easier
since the point of creation would be known, which is desirable for
SAMs.

You could go further and allow short syntax for SAMs instead of lambda
conversion to SAMs, i.e.:

Runnable run = new #Runnable() ( expression );

Again the new, if used in lambdas, would aid consistency across
similar declarations:

#< void() > lam = new #< void() > ( expression );
Runnable run = new #Runnable() ( expression );
Runnable run = new Runnable() {
  public void run() { return expression; }
};

For completeness an example with generics:

Callable< Void > call = new #Callable< Void >() ( expression );

(This suggestion above for SAMs is obviously similar to the CICE
proposal and also similar to comments Josh Bloch has made on this
forum.)

On 12 March 2010 11:38, Neal Gafter <neal at gafter.com> wrote:
> On Thu, Mar 11, 2010 at 4:24 PM, Jesse Kuhnert <jkuhnert at gmail.com> wrote:
>> Now that we've established what 'new' means, any hints from the people
>> that know what they're doing where the project is heading?
>
> Alex Buckley was pretty clear that the lambda specification should not
> dictate when the allocation occurs.  That is nearly the same thing as
> not dictating that each invocation of a lambda expression results in a
> distinct value.  In other words, it conflicts with the meaning of
> 'new'.
>
> This does not work for the conversion to SAM classes, as user code
> executes to perform the construction.  That must be visible at compile
> time (checked exception checking for exceptions thrown by the
> constructor) and runtime (the constructor code executes).  We have yet
> to see how project lambda will address that dilemma  So far there is
> no proposed syntax for the lambda conversion into which "new" could be
> shoehorned.
>



-- 
  -- Howard.


More information about the lambda-dev mailing list