[plt-scheme] paren-shape bug?
Looks like a bug in syntax templates: If the first thing inside the
brackets is an ellipsis pattern, then the paren-shape property is not
applied to the result. Here are some more examples:
#lang scheme
(define-syntax propbotch*
(syntax-rules ()
((_ K [in ...])
(list (K [in ...])
(K [(in 5) ...])
(K [(in 5) ... 10])
;; Next one works, since ellipsis pattern not first!
(K [1 in ...])))))
(define-syntax (propt stx)
(syntax-case stx ()
((_ hd)
(with-syntax ((shape (syntax-property #'hd 'paren-shape)))
#'(quote shape)))))
(propbotch* propt [a b c])
;; => (#f #f #f #\[)
----
At first, I thought it might be this issue: "Properties are not
preserved for a syntax-quoted syntax object in a compiled form that is
marshaled to a byte string." (http://docs.plt-scheme.org/reference/stxprops.html
)
Beware: if you write macros whose bodies contain square brackets,
those square brackets will turn to round parentheses if you compile
the file. You might want to replace 'syntax' (and 'quasisyntax', et
al) in your language with a version that explicitly preserves those
properties.
Ryan
On Apr 28, 2009, at 1:54 PM, Dimitris Vyzovitis wrote:
> I am trying to debug a paren-shape property loss bug, and I have
> arrived at this little case:
>
> proptest.ss:
> #lang scheme/base
>
> (require "mzprop.ss" (for-syntax scheme/base))
> (provide (all-defined-out))
>
> (define-syntax (propt stx)
> (syntax-case stx ()
> ((_ hd)
> (with-syntax ((shape (syntax-property #'hd 'paren-shape)))
> #'(quote shape)))))
>
>
> mzprop.ss:
> #lang scheme/base
> (provide (all-defined-out))
> (define-syntax propbotch
> (syntax-rules ()
> ((_ K in ...)
> (K [in ...]))))
>
>
> $ mzscheme
> Welcome to MzScheme v4.1.5.4 [3m], Copyright (c) 2004-2009 PLT
> Scheme Inc.
>> (require "mzprop.ss" "proptest.ss")
>> (propt [a b c])
> #\[
>> (propbotch propt a b c)
> #f
>
> What happened to my paren-shape?
>
> -- vyzo
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme