From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1512 invoked by alias); 17 Sep 2017 18:54:43 -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 1168 invoked by uid 89); 17 Sep 2017 18:54:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 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-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Sep 2017 18:54:32 +0000 Received: by mail-wm0-f46.google.com with SMTP id 13so17580747wmq.2 for ; Sun, 17 Sep 2017 11:54:31 -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=lciK6pBQsVLliwgA7MtbBZhH2vlQn1Jnu4+x5eDLXpY=; b=Lr+zdGVjhH96VSJG4QqFS70suMS0UGtBhXr8QHcu3f5Qz39s5FMfxYh35s0mBU2Q2x 9EAs8ivYUWO2uWKnhLYZg06neOZZDBMk774c0XKrz/BzceMkkpAmSUiMKyiHJEFHQuYh bXp5QIj+/nHaatssUgdR7TBAupEIDiG+dcohyPJIDFS4LhqCQfYqmfu8U4KZBHpTBTlL H48yMs4lP8lOd8ChO6Sl+wwAT2PTuZojsQWkQgaGcuaeCVLUHa2HjIrmA/pIh1vcNd78 oyCaCLSlgyu6Y8BG977brXMTz4k48/eFdS3Q2E/efPT7tmv57Cx1iw3Mf16BpEEoytD+ BhzA== X-Gm-Message-State: AHPjjUicuvAdTTB7Dbd7fJX/YnpS16FpUn5Nv/X7QtxwB4glQNd0IaWz oJgwSF6Vv5A7ncMcpIS092wDLuG1DAXSqRcGWf0= X-Google-Smtp-Source: AOwi7QB7jkLS80vghusSHEI9iHIT9fbpnJUInDggl9hhC5CBmnrora+hOJcoB12ob9f2OPjLYgOdhxdzvCBO3Aff7uo= X-Received: by 10.28.199.13 with SMTP id x13mr3659415wmf.124.1505674469887; Sun, 17 Sep 2017 11:54:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.200.2 with HTTP; Sun, 17 Sep 2017 11:54:29 -0700 (PDT) In-Reply-To: <5319927a-872b-bf10-59a5-10b25b24343b@bothner.com> References: <5319927a-872b-bf10-59a5-10b25b24343b@bothner.com> From: Sonny To Date: Sun, 17 Sep 2017 18:54: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/msg00055.txt.bz2 this is a big problem for my use case... i wouldn't be able to do something like this on android at runtime (object (java.lang.Runnable) ((run (a ::void))::void (+ 1 1) )) On Sun, Sep 17, 2017 at 9:50 AM, Per Bothner wrote: > On 09/17/2017 09:03 AM, Sonny To wrote: >> >> Thanks for the explanation. However, I'm still not clear about >> compile-time. I'm evaluating this in the TelnetRepl. its interpreted >> no? > > > Yes and no. "Compile-time" is when the Scheme expression is parsed, > analyzed, and (normally) translated to JVM bytecode. On most platforms, > even when you type an expression into a REPL, it gets translated to bytecode > and then loaded on-the-fly using java.lang.ClassLoader.defineClass. > > Because Android doesn't have ClassLoader.defineClass (because it uses dex), > we don't translate REPL input to bytecode. Instead, there is an > interpreter that evaluates to tree (Expression) form of the expression. > > Determining when "SAM-conversion" (converting lambda to anonymous class) > is allowed is done at compile-time. On most platforms, creating the > anonymous class is also done at time-time. On Android, the last step is > deferred to run-time, using a ProcedurallProxy class, but that only supports > converting a lambda to an interface, not a class. > > It probably wouldn't be difficult to use ProcedurallProxy at run-time to > convert > a procedure value to a class instance. However, it would require changes to > error handling: Instead of compiling a simple cast, we have to compile to a > more > complex (and slower) procedure. There is also a question of what warning > messages, > if any to emit. Perhaps worth revisiting if/when we implement > "Optional strict typing along with an explicit dynamic type" > (https://www.gnu.org/software/kawa/Ideas-and-tasks.html#Optional-strict-typing-along-with-an-explicit-dynamic-type). > > (The 'dynamic' type is already partially supported.) > > -- > --Per Bothner > per@bothner.com http://per.bothner.com/