[plt-scheme] define-syntax help

From: support at taxupdate.com (support at taxupdate.com)
Date: Wed Mar 21 13:28:00 EDT 2007

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)

I'd like to define syntax for lookup, so that:

(lookup you main) => "joe"
(lookup you aux)  => "sue"

(register me (lookup you) main) ;; me gets value "joe", lookup assumes mod=main
(register me2 (format "~a smith" (lookup you aux)) main) ;; me2 gets value "sue smith"

Is it possible to code lookup with the ability to see the 'mod' value from
the 'register' syntax?


Posted on the users mailing list.