From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6876 invoked by alias); 17 Sep 2017 16:04:09 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 6861 invoked by uid 89); 17 Sep 2017 16:04:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Sep 2017 16:03:58 +0000 Received: by mail-wr0-f174.google.com with SMTP id w12so4586426wrc.7 for ; Sun, 17 Sep 2017 09:03:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=30CRVwCDcIg2nCukPotfwyydIz11wgNcT2tLvusp5uI=; b=QITBwJSeYmugiy5SXHwJJ6TINm7VMO+vg8iMydITZZTkxjTLwvSp/gVmPCITrqBvDB QWniQpz1NurrJXeOqcqW3ec92zEftYwcd/zhJCXCYyA48Vmt2DZ5zAjhnK+GahazxS+X zu6hWfCB15r/uLN8loHlOhkvYVO01H/cWrKULoqxapRl2JY00meJm+Cpa3ENOm1xB5WY ATcQiRI9d8J9lY+t79S3M90AbPp4m4w0YljprfMUUfl4kUibsPj3Ff66cfva/6KYqhFq fE9wy6VwCYXkH3Yxp533pDakI4jqXuU2xa4cz6q1A596fwaVGH95Uo+UypiyyWXamFlm HX4g== X-Gm-Message-State: AHPjjUjbChw69wqNZY9DZE7HPaPIYV3k3lmgYRLAYSIQfm+6Mdbytmfv b/uyra82XPwHQRE37aY0qxaD4RMJbXcvgZ6HHE0= X-Google-Smtp-Source: AOwi7QDURfJdBSvdwpfp5DkrC6Eir3wSrYStzMYZV0pMZc1U3uN4qd1tloMV2pOUzQVFSE9pb5XkJKSyuq7km/rr8ko= X-Received: by 10.223.187.74 with SMTP id x10mr5074982wrg.66.1505664236503; Sun, 17 Sep 2017 09:03:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.200.2 with HTTP; Sun, 17 Sep 2017 09:03:55 -0700 (PDT) In-Reply-To: References: From: Sonny To Date: Sun, 17 Sep 2017 16:04:00 -0000 Message-ID: Subject: Re: using lambda to implement one method interface To: Per Bothner Cc: Kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00050.txt.bz2 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 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/