public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Jamison Hope <jrh@theptrgroup.com>,
	Kawa mailing list <kawa@sourceware.org>
Subject: Re: no class-of ?
Date: Sun, 24 Sep 2017 21:52:00 -0000	[thread overview]
Message-ID: <a8ba6c31-f64f-11a2-e084-3b90251961f6@bothner.com> (raw)
In-Reply-To: <AEA45C97-6B8C-402F-A211-C3C758B136B8@theptrgroup.com>

On 09/23/2017 07:31 AM, Jamison Hope wrote:
> But I get a java.lang.Error when I try to compile that:
> 
> 
> (compiling test.scm to test)
> Exception in thread "main" java.lang.Error: gnu.kawa.lispexpr.LangPrimType does not implement Externalizable
> 	at gnu.expr.LitTable.error(LitTable.java:122)
> ...

The problem is the 'boolean' has language-specific semantics, so the
variable 'boolean' is bound to the field kawa.standard.Scheme.booleanType.
However, the *class* of boolean is a gnu.kawa.lispexpr.LangPrimType, because
of this mismatch, the Kawa compiler doesn't find it when it needs to compile
boolean as a literal.

One could "fix" LangPrimType to implement Externalizable, but that would
create a new object, different from Scheme.booleanType.

A solution would be to create a new subclass SchemePrimType,
and do:
     public static final LangPrimType booleanType = SchemePrimType,booleanType;

Instead, I implemented a somewhat more general mechanism: If an object that
needs to be referenced as a literal implements HasOwningField, we use the
getOwningField of that interface to find the corresponding static field.

> If I change the test to "(eq? t0 integer)" or "(eq? t0 byte)", then it
> compiles without error, so it's something about boolean in particular.

Yes, integer is bound to LangPrimType.intType.  Since the code for compiling literals
looks for the class of the value, it can easily find the field.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

  reply	other threads:[~2017-09-24 21:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 11:11 Sonny To
2017-09-21 15:24 ` Per Bothner
2017-09-22 18:29   ` Jamison Hope
2017-09-22 19:23     ` Per Bothner
2017-09-22 22:18       ` Jamison Hope
2017-09-22 22:26         ` Per Bothner
2017-09-23 14:31           ` Jamison Hope
2017-09-24 21:52             ` Per Bothner [this message]
2017-09-25 16:58               ` Jamison Hope
2017-09-25 17:19                 ` Per Bothner

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=a8ba6c31-f64f-11a2-e084-3b90251961f6@bothner.com \
    --to=per@bothner.com \
    --cc=jrh@theptrgroup.com \
    --cc=kawa@sourceware.org \
    /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).