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]

unknown allocation kind '#<syntax (quote static) in #8>'


In a macro expanding to a define-simple-class, if a field init: form
references a macro argument, then that field's allocation: expression
will result in an error like the one in the subject line.

For instance:

$ cat /tmp/test1.scm
(define-syntax define-documented-class
  (syntax-rules ()
    ((define-documented-class name supers docstr rest ...)
     (define-simple-class name supers
       (docstring ::String allocation: 'static init: docstr)
       rest ...))))

(define-documented-class vec2d ()
  "A 2D vector."
  (x ::double)
  (y ::double))


(format #t "~A~%" vec2d:docstring)

$ java kawa.repl -f /tmp/test1.scm
gnu.text.SyntaxException:
/tmp/test1.scm:8:1: unknown allocation kind '#<syntax (quote static) in #8>'
at kawa.Shell.run(Shell.java:257)
at kawa.Shell.runFile(Shell.java:489)
at kawa.Shell.runFileOrClass(Shell.java:427)
at kawa.repl.processArgs(repl.java:216)
at kawa.repl.main(repl.java:831)


If that "init: docstr" is changed, then the error goes away:

$ cat /tmp/test2.scm
(define-syntax define-documented-class
  (syntax-rules ()
    ((define-documented-class name supers docstr rest ...)
     (define-simple-class name supers
       (docstring ::String allocation: 'static init: "literal")
       rest ...))))

(define-documented-class vec2d ()
  "A 2D vector."
  (x ::double)
  (y ::double))


(format #t "~A~%" vec2d:docstring)

$ java kawa.repl -f /tmp/test2.scm
literal


I'm not really sure why that makes a difference, but the attached patch
fixes it:

$ svn diff kawa/standard/object.java
Index: kawa/standard/object.java
===================================================================
--- kawa/standard/object.java	(revision 7059)
+++ kawa/standard/object.java	(working copy)
@@ -188,6 +188,8 @@
 		    nKeywords++;
 		    pair = (Pair) args;
 		    Object value = pair.getCar();
+                    while (value instanceof SyntaxForm)
+                      value = ((SyntaxForm)value).getDatum();
 		    args = pair.getCdr();
 		    if (key == coloncolon || key == typeKeyword)
 		      typePair = pair;



$ kawa -f /tmp/test1.scm
A 2D vector.

-Jamie


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


Attachment: object.patch
Description: Binary data


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