Hi guys, 
I’ve been working with Racket 6.5 refreshing my macro knowledge and ran into a 
situation with format-id that baffles me. There’s an example of format-id on 
the “Fear of Macros” webpage that puzzles me. 

>(require (for-syntax racket/syntax))
>(define-syntax (hyphen-define/ok3 stx)
    (syntax-case stx ()
      [(_ a b (args ...) body0 body ...)
       (with-syntax ([name (format-id stx "~a-~a" #'a #'b)])
         #'(define (name args ...)
             body0 body ...))]))
>(hyphen-define/ok3 bar baz () #t)
>(bar-bas)
#t

So far so good… so I tried a few other arguments:

>(hyphen-define/ok3 bar ? () #t)
>(bar-?)
#t

>(hyphen-define/ok3 bar 7 () #t)
>(bar-7)
 ../../Applications/Racket v6.5/collects/racket/private/map.rkt:26:19: 
format-id: contract violation
  expected: (or/c string? symbol? identifier? keyword? char? number?)
  given: #<syntax:16:23 7>

That was a surprise. So ids can’t have numerics as part of their arguments in 
format-id? Is that correct? How would I make this work if I wanted to pass 
numbers into the format-id to generate ids like foo7, bar3, etc?

Thanks so much for any insight into this!

-Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to