[plt-scheme] define-syntax help

From: David Einstein (deinst at gmail.com)
Date: Thu Mar 22 13:33:48 EDT 2007

I agree that it is less than clear, but I think that what is trying to be done
is to have the hash table populated at syntax time.

To do this, the defines
should be changed to define-for-syntax, and

#`(hash-table-put! *field-hash* (make-key 'mod 'sym) val))))

should become something like

(begin
  (hash-table-put! *field-hash* (make-key 'mod 'sym) val)
  #'(whatever you want at run time))

Read section 12.3.3 of the language manual, and things should be clearer,
at least you can ask a question that is likely to be answered.



On 3/22/07, Noel Welsh <noelwelsh at yahoo.com> wrote:
> Perhaps I'm missing something.  Why not make these functions?
>
> N.
>
>
>
> ----- Original Message ----
> From: "support at taxupdate.com" <support at taxupdate.com>
>
> Given the following:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define *field-hash* (make-hash-table))
> (define (make-key mod sym)
>   (string->symbol (format "~a.~a" mod sym)))
> (define-syntax (register stx)
>  (syntax-case stx ()
>   ((_ sym val mod)
>    #`(hash-table-put! *field-hash* (make-key 'mod 'sym) val))))
>
> (reqister you "joe" main)
> (register you "sue" aux)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ...
>
>
>
>
>
>
> ____________________________________________________________________________________
> Food fight? Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink Q&A.
> http://answers.yahoo.com/dir/?link=list&sid=396545367
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.