public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Question: Declaring type to be a Class defined and included inside the same or child library
@ 2019-12-03 20:45 spellcard199
  0 siblings, 0 replies; only message in thread
From: spellcard199 @ 2019-12-03 20:45 UTC (permalink / raw)
  To: kawa

Hello. I'm writing here because I'm not sure if this Kawa behavior is the expected one or it's an issue.

I have 3 files:
- 1 file with the library definition
- 2 files, each containing one class

One of the 2 classes has a field whose type is the class defined in the other file.

Minimal Example (I could make it in a single file, but I'm putting the emphasis on the `include`, since `load` works instead)

Class1.scm

  (define-simple-class Class1 ())

Class2.scm

  (define-simple-class Class2 ()
    (x ::<Class1>)
    ((*init*)
     (set! x (Class1))))

foobar.sld

  (define-library (xxx)
    (import (kawa base))
    (include "Class1.scm")
    (include "Class2.scm"))

When I do... :

  kawa -f foobar.sld

... I get an exception:

  Class2.scm:4:4: caught exception in inliner for #<procedure gnu.kawa.functions.AppendValues> - java.lang.RuntimeException: no such class: Class1

I can avoid the exception:
- removing the type declaration
- using `(load "Class2.scm")` instead of `(include "Class2.scm")` in foobar.sld

At the moment I'm using the second option and it works fine for me.

The thing that made me ask instead of assuming this is the expected behavior is that it's ok to use Class1 as a superclass of Class2, so Class2 does "see" Class1. For example, this does not raise an exception:

  (define-simple-class Class2 (Class1)
    (x)
    ((*init*)
     (set! x (Class1))))

So my question is: am I doing it the wrong way or is it a Kawa issue? Should I open an issue in the Kawa repo?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-03 20:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 20:45 Question: Declaring type to be a Class defined and included inside the same or child library spellcard199

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).