public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Arvydas Silanskas <nma.arvydas.silanskas@gmail.com>
Cc: kawa mailing list <kawa@sourceware.org>
Subject: Re: First-class continuations in Kawa
Date: Sun, 8 Aug 2021 16:52:47 -0700	[thread overview]
Message-ID: <a6f5229d-4c59-7495-1103-179745f5abf2@bothner.com> (raw)
In-Reply-To: <CAPh7weBepqBVmKarG07NdphAsWfrbUVxxV=2YAONsTPFUH4EBg@mail.gmail.com>



On 8/8/21 7:29 AM, Arvydas Silanskas wrote:
> I merged and got the original code mostly working (leaving optimization refactoring for later),

Cool.

> var foo = (FooInterface) Class.forName("Foo").newInstance();
> foo.bar();
> ```
> 
> where FooInterface is an interface written in java, and Foo is a class created by `define-simple-class` on kawa side which specifies said interface as one of its supers.
> 
> * Am I using the recommended approach for java -> kawa interaction?

For the simple case. But clearly it might not work in general.

Does what you're trying to work when Foo is compiled with --full-tailcalls ?
The latter also makes use of a top-level handling loop, but there are automatic
"bridges" between the two styles of functions (see CallContext.runUntilDone).

Based on a trivial test, a bar method in a Foo class under --full-tailcall just becomes
a plain Java method (without tail-call support).

> * If yes to the first question, do we strongly care that this type of calling gets broken as a compromise? After all the (optionally enabled, by default disabled) full continuations will weaken interop anyway, so maybe this is not worth trying to save. I'm not certain what a fix would be, maybe some sort of custom equivalent to Class.forName, which would return a proxied class with the handling loop attached to the methods.

I think its ok to require people to write wrapper code in Scheme
when generating "simple" classes.

> * The points about using CPStyle / CALL_WITH_TAILCALLS from what I can understand are purely regarding optimizations, right? Or do you think that refactored code using those approaches would also solve the problem above?

Implementing CPStyle / CALL_WITH_CONTINUATIONS is mostly performance.
However, since CALL_WITH_CONTINUATIONS is sort of an extension of CALL_WITH_TAILCALLS,
I think the whole system would be better integrated.  Specifically having a single
CallContext.runUntilDone with that handles both continuations and tail-calls
would be preferable.   (I think I haven't looked much at this code in a while.)
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

  parent reply	other threads:[~2021-08-08 23:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-20  0:49 Duncan Mak
2018-01-20  6:47 ` Per Bothner
2018-01-20 16:07   ` Duncan Mak
2018-01-20 23:20     ` Andrea Bernardini
2018-02-21  0:21       ` Andrea Bernardini
2018-02-22  0:38         ` Duncan Mak
2021-05-01 16:15           ` Duncan Mak
2021-05-01 18:45             ` Arvydas Silanskas
2021-05-01 19:06               ` Sudarshan S Chawathe
2021-05-01 20:38                 ` Per Bothner
2021-06-09  9:04                   ` Arvydas Silanskas
2021-06-09 23:27                     ` Per Bothner
2021-08-08 14:29                       ` Arvydas Silanskas
2021-08-08 15:53                         ` Andrea Bernardini
2021-08-08 23:52                         ` Per Bothner [this message]
2021-08-09 19:41                           ` Per Bothner
2022-12-07 23:42                             ` Duncan Mak
2022-12-09 10:53                               ` Arvydas Silanskas

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=a6f5229d-4c59-7495-1103-179745f5abf2@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    --cc=nma.arvydas.silanskas@gmail.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).