This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
porting OOPS issues...
- From: Richard Polfreman <R dot P dot Polfreman at herts dot ac dot uk>
- To: kawa at sources dot redhat dot com
- Date: Tue, 9 Jul 2002 14:32:08 +0100
- Subject: porting OOPS issues...
Hi,
I'm trying to get Elk's OOPS working in Kawa so that control files
using OOPS can be used in Kawa. OOPS is a very small object
system so I didn't think it would be too difficult. I'm no Scheme
expert and am having a problem with the following (Kawa 1.6.99):
(define-macro (define-method class lambda-list . body)
(if (not (pair? lambda-list))
(error 'define-method "bad lambda list"))
`(begin
(check-class 'define-method ,class)
(let ((env (class-env ,class))
(method (car ',lambda-list))
(args (cdr ',lambda-list))
(forms ',body)
)
(eval `(define ,method (lambda ,args ,@forms)) env)
#!void)))
==> "invalid use of unquote splicing in quasiquote template":
where define-macro is defined as:
(posted on this list by Joerg-Cyril Hochle)
(defmacro define-macro (bindings . body)
(if (pair? bindings)
`(defmacro ,(car bindings) ,(cdr bindings) ,@body)
(let ((rest gentemp))
`(defmacro ,bindings ,rest (apply ,@body ,rest)))))
Is this a bug in Kawa, or is there something fundamentally wrong
here? I tried rewriting using straight defmacro but got the same
problem. Removing the unquote splicing does not give desired results
although does successfully define the macro....
Also on the subject of OOPS, it seems that it uses a different
environment
for each class/instance for storing their methods (with data just stored
in a vector), and
a record of this environment stored in the class/instance vector.
This works on the basis that evaluating a procedure creates a new
environment
(which is what we expect from the description in SICP?). Thus if we
define foo:
(define foo (lambda () (the-environment))
evaluating this in Elk always gives a different environment (the new one
created for evaluation?)
but in Kawa this always gives the current environment in which foo is
called, e.g. the
interaction environment of the interpreter. Should Kawa behave in this
way?
I've tried to get round this by getting a new environment from the
Scheme class whenever a
(OOPS) define-class or make-instance is called, is this likely to cause
problems?
I'm having a couple of problems searching an environment and getting a
list of bound symbols
but that can wait for another post! (it seems the procedure works if I
define it in the interpreter but
gives errors if it was loaded at startup....)
Richard.
_______________________________________________
Richard Polfreman
Music Department
Faculty of Engineering & Information Sciences
College Lane, Hatfield, Herts.
Al 10 9AB UK
Email: R.P.Polfreman@herts.ac.uk
Vox: +44 1707 286473
________________________________________________