From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: Per Bothner <per@bothner.com>
Cc: kawa@sourceware.org
Subject: Re: A protected slot is not accessible in a subclass
Date: Fri, 25 Mar 2022 21:53:42 +0100 [thread overview]
Message-ID: <CAMFYt2ZFfOYm2Sd+6dkRHN++JbiumFfuAbVERyRLx4rwQAt+_g@mail.gmail.com> (raw)
In-Reply-To: <8a9b979c-e33d-7e38-9f4c-039092d8169b@bothner.com>
pt., 25 mar 2022 o 19:46 Per Bothner <per@bothner.com> napisał(a):
>
>
> On 3/25/22 02:59, Panicz Maciej Godek wrote:
> > I tried this:
> > (define-simple-class S (gnu.mapping.Symbol)
> > ((*init*)
> > (invoke-special gnu.mapping.Symbol (this) '*init*
> (("foo":toString):intern) gnu.mapping.Namespace:EmptyNamespace)
> > (set! (field (this) 'name) (("bar":toString):intern))))
> > but it gives a similar error:
> > java.lang.RuntimeException: no such field name in S
> > at gnu.kawa.reflect.SlotSet.apply(SlotSet.java:115)
> at gnu.kawa.reflect.SlotSet.apply3(SlotSet.java:120)
> > at S.<init>(tty:14)
>
> This fails because the (set! (field ...) ...) isn't inlined, so we end up
> using
> run-time reflection. This is a missing Kawa optimization.
>
> Using set-field! instead does work:
>
> (set-field! (this) 'name (("bar":toString):intern))
>
> Note in this case you need to add:
>
> (import (kawa reflect)) ; for set-field!
>
Yes, that one works! Thanks!
>
> I checked in a fix so either of these now work:
>
> (set! (this):name (("bar":toString):intern))
> (set! name (("bar":toString):intern))
>
>
This one works now too, thanks a lot!
prev parent reply other threads:[~2022-03-25 20:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 22:14 Panicz Maciej Godek
2022-03-25 4:56 ` Per Bothner
2022-03-25 9:59 ` Panicz Maciej Godek
2022-03-25 18:46 ` Per Bothner
2022-03-25 20:53 ` Panicz Maciej Godek [this message]
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=CAMFYt2ZFfOYm2Sd+6dkRHN++JbiumFfuAbVERyRLx4rwQAt+_g@mail.gmail.com \
--to=godek.maciek@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).