On 5-Aug-09, at 5:49 PM, lowly coder wrote:
foo.scm:
(namespace ("foo#")) (##define define 2) [some code] (my-define ...) define
Is there something I can replace [some code] with, so that:
- I'm still in namespace foo#
- foo#my-define = ""#define
- define still has value 2 on the last line
[I'm doing some weird tricks where define does type checking on its args at run time.]
It should work as-is. You'll have to define my-define as a macro which expands to ##define.
Something like:
(namespace ("foo#")) (##include "~~lib/gambit#.scm")
(##define-macro (my-define call-pattern . body) `(##define ,call-pattern (pretty-print ',(car call-pattern)) ,@body))
(my-define (f x) (* x x))
(pretty-print (+ (f 1) (f 2))) ; => prints f twice then returns 5
BTW, you can't (##define define 2) because "define" is a macro, so you can't use it as a variable. However you could give a different macro definition to "define".
Marc