Why can't I do the following:
(define-macro (module name) ,(begin (##namespace (string-append (object->string ,name) "#")) (##include "~~lib/gambit#.scm")))
?
Afficher les réponses par date
On Tue, Jul 14, 2009 at 8:35 PM, lowly coderlowlycoder@huoyanjinjing.com wrote:
(define-macro (module name) ,(begin (##namespace (string-append (object->string ,name) "#")) (##include "~~lib/gambit#.scm")))
Try using `##define-macro' instead of `define-macro'.
Best wishes,
-Ben
On Tue, Jul 14, 2009 at 10:09 PM, Ben Weaverben@orangesoda.net wrote:
Try using `##define-macro' instead of `define-macro'.
Apologies, I was hasty and didn't try my suggestion before replying. It seems that you need to use identifers bound in the gambit namespace (##) to make this macro work; otherwise an "Ill-defined 'namespace'" error keeps cropping up. The following works for me:
(##namespace ("module-system#"))
(##define-macro (module name) (##quasiquote (##begin (##namespace (,(##string-append (##symbol->string name) "#"))) (##include "~~lib/gambit#.scm"))))
(module bar)
(define quux 1)
quux ; ==> 1 bar#quux ; ==> 1
May be:
(define-macro (module name) `(begin (##namespace (,(string-append (symbol->string name) "#"))) (##include "~~lib/gambit#.scm")))
Works fine.
Vasil.
Why can't I do the following:
(define-macro (module name) ,(begin (##namespace (string-append (object->string ,name) "#")) (##include "~~lib/gambit#.scm")))
? _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
2009/7/15 lowly coder lowlycoder@huoyanjinjing.com:
Why can't I do the following: (define-macro (module name) ,(begin (##namespace (string-append (object->string ,name) "#")) (##include "~~lib/gambit#.scm")))
Because nesting two unquotes without any backquote is likely to be meaningless. Because even if you did that properly, (string-append (o->s ,name) "#") is still a list whose CAR is string-append, instead of being a string (or a list whose CAR is a string, I dunno the syntax of namespaces). Because if you hade done the two above steps properly, it would probably work.
(define-macro (module name) `(begin (##namespace (,(string-append (object->string name) "#"))) (##include "~~lib/gambit#.scm"))) (module tata) (define toto 0) (pretty-print tata#toto)
Does this do what you want?
P!
Yeah -- sorry for wastiing everyone's time.
On Tue, Jul 14, 2009 at 10:49 PM, Adrien Piérardpierarda@iro.umontreal.ca wrote:
2009/7/15 lowly coder lowlycoder@huoyanjinjing.com:
Why can't I do the following: (define-macro (module name) ,(begin (##namespace (string-append (object->string ,name) "#")) (##include "~~lib/gambit#.scm")))
Because nesting two unquotes without any backquote is likely to be meaningless. Because even if you did that properly, (string-append (o->s ,name) "#") is still a list whose CAR is string-append, instead of being a string (or a list whose CAR is a string, I dunno the syntax of namespaces). Because if you hade done the two above steps properly, it would probably work.
(define-macro (module name) `(begin (##namespace (,(string-append (object->string name) "#"))) (##include "~~lib/gambit#.scm"))) (module tata) (define toto 0) (pretty-print tata#toto)
Does this do what you want?
P!
-- Français, English, 日本語, 한국어
I think my intervention sounded rude. Sorry if it did, that was not my intention. Besides the trivial syntax errors (which I thought were just a bad copy-by-hand of source code), I saw no reason for it not to work.
P!
2009/7/15 lowly coder lowlycoder@huoyanjinjing.com:
Yeah -- sorry for wastiing everyone's time.
On Tue, Jul 14, 2009 at 10:49 PM, Adrien Piérardpierarda@iro.umontreal.ca wrote:
2009/7/15 lowly coder lowlycoder@huoyanjinjing.com:
Why can't I do the following: (define-macro (module name) ,(begin (##namespace (string-append (object->string ,name) "#")) (##include "~~lib/gambit#.scm")))
Because nesting two unquotes without any backquote is likely to be meaningless. Because even if you did that properly, (string-append (o->s ,name) "#") is still a list whose CAR is string-append, instead of being a string (or a list whose CAR is a string, I dunno the syntax of namespaces). Because if you hade done the two above steps properly, it would probably work.
(define-macro (module name) `(begin (##namespace (,(string-append (object->string name) "#"))) (##include "~~lib/gambit#.scm"))) (module tata) (define toto 0) (pretty-print tata#toto)
Does this do what you want?
P!
-- Français, English, 日本語, 한국어