This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: no class-of ?
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/