From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92066 invoked by alias); 17 Sep 2017 16:50:27 -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 91407 invoked by uid 89); 17 Sep 2017 16:50:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=dex X-HELO: aibo.runbox.com Received: from dns3.teletopia.net (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Sep 2017 16:50:15 +0000 Received: from [10.9.9.211] (helo=mailfront11.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dtclp-0005J9-35; Sun, 17 Sep 2017 18:50:13 +0200 Received: from 70-36-239-177.dsl.dynamic.fusionbroadband.com ([70.36.239.177] helo=localhost.localdomain) by mailfront11.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1dtclh-0006hy-Qr; Sun, 17 Sep 2017 18:50:06 +0200 Subject: Re: using lambda to implement one method interface To: Sonny To Cc: Kawa mailing list References: From: Per Bothner Message-ID: <5319927a-872b-bf10-59a5-10b25b24343b@bothner.com> Date: Sun, 17 Sep 2017 16:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00051.txt.bz2 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/