So in an attempt to improve my understanding of Racket Macros, I thought I'd implement the following syntax change to Racket: Introduce an alternative syntax for pairs where they are delimited by ':' in addition to ' . ', ie:
"a":"b" => '("a" . "b") Seemed simple enough. I hooked into #%top, split any identifiers on ":" and reconstructed the syntax. I also always quote the left match which catches unbound identifiers ala javascript style object keys. But, now I want 1:2 => '(1 . 2) "1":2 => '("1" . 2) Doing a regex-match loses the original typing information unless I (manually?) store it before symbol->string conversion. What's worse, I also want: (define x 3) k:x => '(k . 3) But my naive approach loses the binding information along with the typing. My questions are: 1.) Is my strategy wrong? Should I just tell the Reader to convert any x:y into (cons x y) and let the expander figure out the rest? Are there general guidelines to follow in this regard? (Syntax => Reader, Semantics => Expander)?? 2.) If I stick with macros, what tactics should I be using to avoid the problems I have above? I'm sure that binding/typing information is a basic concern well addressed by Racket. I've dug through the bound-identifier=?<http://docs.racket-lang.org/reference/stxcmp.html#%28def._%28%28quote._~23~25kernel%29._bound-identifier~3d~3f%29%29> stuff a bit, but my understanding is clearly lacking and before I go about reconstructing lexical information ad-hoc I thought I'd post this as a sanity check to point me in the right direction. Thanks for your help. -- Talk to you soon, Scott Klarenbach PointyHat Software Corp. www.pointyhat.ca p 604-568-4280 e sc...@pointyhat.ca 200-1575 W. Georgia Vancouver, BC V6G2V3 _______________________________________ To iterate is human; to recur, divine
____________________ Racket Users list: http://lists.racket-lang.org/users