[racket-dev] paren-shape question

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Sun Mar 25 20:05:56 EDT 2012

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!

Posted on the dev mailing list.