[racket-dev] paren-shape question

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Mar 25 20:09:25 EDT 2012

It comes from the way syntax properties are propagated through macro
transformers. There is some explanation of this in the docs; search
for syntax-property and scroll up.

Robby

On Sun, Mar 25, 2012 at 7:05 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
> I'm getting confused by some behavior with regards to paren-shape.
> Here's what I see:
>
> #lang racket
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define-for-syntax (square-brackets? stx)
>  (eq? (syntax-property stx 'paren-shape) #\[))
>
> (define-syntax (square-app stx)
>  (syntax-case stx ()
>    [(_ op ...)
>     (square-brackets? stx)
>     (syntax-property (syntax/loc stx (app op ...))
>                      'paren-shape
>                      #\[)]))
>
> (define-syntax (app stx)
>  (syntax-case stx ()
>    [(_ op ...)
>     (square-brackets? stx)
>     #'(#%app op ...)]
>    [else
>     (raise-syntax-error #f
>                         (format "expected square brackets.  Paren shape is: ~s"
>                                 (syntax-property stx 'paren-shape))
>                         stx)]))
>
> [square-app + 3 4]
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> When I run this, I see the following error message:
>
>    app: expected square brackets.  Paren shape is: (#\[ . #\[) in: (app + 3 4)
>
>
> I do not understand why the paren-shape is a cons pair.  Where did
> that come from?
>
>
> Thanks!
> _________________________
>  Racket Developers list:
>  http://lists.racket-lang.org/dev


Posted on the dev mailing list.