This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: using lambda to implement one method interface


Thanks for the explanation. However, I'm still not clear about
compile-time. I'm evaluating this in the TelnetRepl. its interpreted
no?

On Sun, Sep 17, 2017 at 8:59 AM, Per Bothner <per@bothner.com> wrote:
> On 09/17/2017 08:38 AM, Sonny To wrote:
>>
>> this works
>>
>> (let ((handler (android.os.Handler (android.os.Looper:getMainLooper)))
>>        )
>>    (handler:post (lambda ()
>>                          (android.util.Log:i "scm" "run me")))
>>    )
>>
>> this is non-intuitive. why doesn't it work if i bind the lambda to a
>> symbol? seems like a bug to me
>
>
> Perhaps a documentation bug: It may not be clear that when the manual
> say "required type" in:
>
>     This is possible when the required type is an interface or
>     abstract class with a Single (exactly one) Abstract Methods.
>
> we mean the type required by the *compile-time context* of the expression.
>
> This is a deliberate design limitation, not a bug.  This way the anonymous
> class can be created a compile-time, not run-time.  Doing it at run-time
> would be more difficult and more expensive. Kawa has always put a high
> priority on performance.
>
> Perhaps a future Kawa extension will allow "SAM-conversion" at run-time,
> but it is not currently in the plans.
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]