lambda-repo workaround [was Re: Can't get lambda forest to work]
Andrew John Hughes
ahughes at redhat.com
Thu Jun 17 06:35:17 PDT 2010
On 17 June 2010 14:10, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> On 17/06/10 13:42, Andrew John Hughes wrote:
>> On 17 June 2010 13:28, Maurizio Cimadamore
>> <maurizio.cimadamore at oracle.com> wrote:
>>
>>> This is fixed now.
>>>
>>> Thanks
>>> Maurizio
>>>
>>>
>> Thanks for the quick fix. I noticed an #int(int) won't accept an
>> Integer. Was this a deliberate design decision?
>>
> What do you mean?
>
> #int(int) square = #(int x)(x * x);
> ...
> Integer y = ...
> System.out.println(y + " squared is " + square.(y));
>
> This seems to work just fine...
>
Yeah, I saw your fix.
> Or you mean the #(int)int type won't accept a #(Integer)int type? The
> spec (in their current form) doesn't allow for such interoperability
> (argument types on the RHS need to be supertypes of argument types on
> the LHS).
>
This is what I was referring to. It means to use a map function like
that in the strawman proposal, you need functions which use the boxed
types, not the more usual ones using primitive types.
See http://blog.fuseyism.com/index.php/2010/06/17/higher-level-functions-in-java/
where I did a quick basic implementation of map as a test and run into
this issue.
> Maurizio
>>
>>> On 17/06/10 13:14, Maurizio Cimadamore wrote:
>>>
>>>> On 17/06/10 13:06, Andrew John Hughes wrote:
>>>>
>>>>
>>>>> public static void main(String[] args)
>>>>> {
>>>>> #int(int) square = #(int x)(x * x);
>>>>> #int() fortyTwo = #()(42);
>>>>> Integer y = Integer.parseInt(args[0]);
>>>>> System.out.println("Hello, the meaning of life is " + fortyTwo.());
>>>>> System.out.println(y + " squared is " + square.(y));
>>>>>
>>>>>
>>>>>
>>>>>
>>>> This is a straight prototype bug ;-)
>>>> I have a fix for it will be pushing it soon. The problem is the boxing
>>>> (you are passing a Integer where the closure accepts a 'int'). The
>>>> prototype works ok, but an assertion causes the crash (disabling
>>>> assertions also works fine).
>>>>
>>>> Maurizio
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>
--
Andrew :-)
Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)
Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
More information about the lambda-dev
mailing list