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

Jamison Hope jrh@theptrgroup.com
Wed Oct 5 23:17:00 GMT 2011


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: object.patch
Type: application/octet-stream
Size: 523 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/kawa/attachments/20111005/92d773d4/attachment.obj>


More information about the Kawa mailing list