From: Sonny To <son.c.to@gmail.com>
To: Per Bothner <per@bothner.com>
Cc: Kawa mailing list <kawa@sourceware.org>
Subject: Re: using lambda to implement one method interface
Date: Sun, 17 Sep 2017 18:54:00 -0000 [thread overview]
Message-ID: <CAJxjsJvOTR+iOpf=jXVJqez+1cNQH2xxk67VRtOeLeQ-840P5g@mail.gmail.com> (raw)
In-Reply-To: <5319927a-872b-bf10-59a5-10b25b24343b@bothner.com>
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 <per@bothner.com> 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/
next prev parent reply other threads:[~2017-09-17 18:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 15:32 Sonny To
2017-09-17 15:38 ` Sonny To
2017-09-17 15:59 ` Per Bothner
2017-09-17 16:04 ` Sonny To
2017-09-17 16:50 ` Per Bothner
2017-09-17 18:54 ` Sonny To [this message]
2017-09-17 20:02 ` Per Bothner
2017-09-18 6:35 ` Sonny To
2017-09-18 8:17 ` Sonny To
2017-09-18 13:59 ` Per Bothner
2017-09-18 11:22 ` Sudarshan S Chawathe
2017-09-18 14:24 ` Per Bothner
2017-09-18 14:31 ` Sudarshan S Chawathe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJxjsJvOTR+iOpf=jXVJqez+1cNQH2xxk67VRtOeLeQ-840P5g@mail.gmail.com' \
--to=son.c.to@gmail.com \
--cc=kawa@sourceware.org \
--cc=per@bothner.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).