This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GSOC | Extending Common Lisp support


On Jun 21, 2012, at 9:21 AM, Charles Turner wrote:

So what I think we'd want is instead of IsEqv, IsEq's apply2 method
calling language.booleanType, we'd rather have
Language.getDefault().booleanType. That's a problem because when the
primitives.lisp file is being evaluated, we haven't finished setting
up the Language environment from the common-line parameters. You get
around this for CL by add the following line to initLisp() (which is
eventually called from the repl.java setup when it invokes
Language.getInstance().

Language.setCurrentLanguage(this);

Then we dispatch to the correct booleanType method in Lisp2 and the
correct answer is obtained for the case example.

I'm a little concerned about the correctness of that change to IsEqv. With it in place, what happens if you compile this Scheme function and then invoke it from Common Lisp?

(define (scheme-case)
  (case 'b ((a) 'yes) (else 'no)))

If it works correctly, then fantastic. But my worry is that what will
happen is this:

The Scheme compiler will turn that into something like

Method name:"schemeCase" public static Signature: ()gnu.mapping.SimpleSymbol
Attribute "Code", length:70, max_stack:3, max_locals:0, code_length:28
0: getstatic <Field kawa.standard.Scheme.isEqv gnu.kawa.functions.IsEqv>
3: getstatic <'b>
6: getstatic <'a>
9: invokevirtual <Method gnu.mapping.Procedure.apply2 (java.lang.Object,java.lang.Object)java.lang.Object>
12: getstatic <java.lang.Boolean:FALSE>
15: if_acmpeq 24
18: getstatic <'no>
21: goto 27
24: getstatic <'yes>
27: areturn


Then at runtime from CL, Scheme.isEqv.apply2('b, 'a) will return NIL
and the if_acmpeq check for falsehood will be wrong.


Maybe instead have CommonLisp override #'eqv? with its own instance of IsEqv? That way scheme-case can still call Scheme.isEqv and get #f, and lisp-case

(defun lisp-case ()
  (case 'b ((a) 'yes) (else 'no)))

can call CommonLisp.isEqv and get NIL.

--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]