* module system
@ 2003-05-15 12:42 Dr. Peter Ivanyi
2003-05-15 14:00 ` rm
0 siblings, 1 reply; 5+ messages in thread
From: Dr. Peter Ivanyi @ 2003-05-15 12:42 UTC (permalink / raw)
Hi,
I would like to be able to define a module in the "same" way for guile,
bigloo and plt-scheme, but mostly the first two. I know guile a little
better so I thought I will try to modify the behaviour of guile. In bigloo
a module is defined with
(module ...)
format. So I thought I will write a macro which transforms the bigloo
module definition to guile format. And here I have a little problem.
I have two files:
------------------------------ l.scm ----------------------------
(define-macro (module args)
`(define-module ',@args)
)
(use-modules (m m))
(display var)(newline)
(set! var 5)
(display var)(newline)
------------------------------------------------------------------
------------------------------- m/m.scm --------------------------
(module (m m))
(export var)
(define var #f)
------------------------------------------------------------------
Running this gives the following:
peteri@mercury $ guile -s l.scm
ERROR: no code for module (m m)
If in "l.scm" I use
(defmacro module args
`(define-module ',@args)
)
it gives:
peteri@mercury $ guile -s l.scm
ERROR: In procedure variable-set-name-hint!:
ERROR: Wrong type argument in position 2 (expecting SYMBOLP): (m m)
However if I copy the define-module from "boot-9.scm" into "l.scm" and
rename it to "module" it works. I would like to avoid copying macro from
"boot-9.scm". Can somebody help me to sort out what I am doing wrong?
With the first variation why could it not find the code? The module macro
should expand into the define-module macro which expands further and then
I should have the same effect. But obviously something else is happening.
Thanks for any help.
Peter Ivanyi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: module system
2003-05-15 14:00 ` rm
@ 2003-05-15 13:20 ` Dr. Peter Ivanyi
2003-05-15 14:59 ` rm
0 siblings, 1 reply; 5+ messages in thread
From: Dr. Peter Ivanyi @ 2003-05-15 13:20 UTC (permalink / raw)
Cc: rm
rm@fabula.de wrote:
> Hmm, shouldn't this be
>
> (defmacro module args
> `(define-module ,args))
>
I also tried that. The result is:
peteri@mercury $ guile -s l.scm
ERROR: In procedure variable-set-name-hint!:
ERROR: Wrong type argument in position 2 (expecting SYMBOLP): (m m)
The reason I have tried so many variations is that there is slight
difference between defmacro and define-macro but I could not figure
out what. Sometimes one of them works, sometimes the other.
Peter Ivanyi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: module system
2003-05-15 12:42 module system Dr. Peter Ivanyi
@ 2003-05-15 14:00 ` rm
2003-05-15 13:20 ` Dr. Peter Ivanyi
0 siblings, 1 reply; 5+ messages in thread
From: rm @ 2003-05-15 14:00 UTC (permalink / raw)
Cc: guile-user@gnu.org
On Thu, May 15, 2003 at 01:42:38PM +0100, Dr. Peter Ivanyi wrote:
> Hi,
>
> I would like to be able to define a module in the "same" way for guile,
> bigloo and plt-scheme, but mostly the first two. I know guile a little
> better so I thought I will try to modify the behaviour of guile. In bigloo
> a module is defined with
> (module ...)
> format. So I thought I will write a macro which transforms the bigloo
> module definition to guile format. And here I have a little problem.
> I have two files:
>
> [...]
Hmm, shouldn't this be
(defmacro module args
`(define-module ,args))
hth
Ralf Mattes
> Thanks for any help.
>
> Peter Ivanyi
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: module system
@ 2003-05-15 14:48 Dr. Peter Ivanyi
0 siblings, 0 replies; 5+ messages in thread
From: Dr. Peter Ivanyi @ 2003-05-15 14:48 UTC (permalink / raw)
rm@fabula.de wrote:
> Well, my approach would be like this:
>
> ;; --------------------- File: mod-comp.scm
> (use-modules (ice-9 syncase))
>
> (define-syntax module
> (syntax-rules ()
> ((module (a))
> (define-module (a)))
> ((module (a ...))
> (define-module (a ...)))))
Wow! Thank you. That works. However this a third way to create
macros. :-) As I understand defmacro is different from all others.
(The documentation says this.) But why define-macro is different from
define-syntax ? Shouldn't one expand to the other?
Thanks anyway.
Peter Ivanyi
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: module system
2003-05-15 13:20 ` Dr. Peter Ivanyi
@ 2003-05-15 14:59 ` rm
0 siblings, 0 replies; 5+ messages in thread
From: rm @ 2003-05-15 14:59 UTC (permalink / raw)
Cc: rm
On Thu, May 15, 2003 at 02:20:35PM +0100, Dr. Peter Ivanyi wrote:
> rm@fabula.de wrote:
>
> > Hmm, shouldn't this be
> >
> > (defmacro module args
> > `(define-module ,args))
> >
>
> I also tried that. The result is:
>
> peteri@mercury $ guile -s l.scm
> ERROR: In procedure variable-set-name-hint!:
> ERROR: Wrong type argument in position 2 (expecting SYMBOLP): (m m)
>
> The reason I have tried so many variations is that there is slight
> difference between defmacro and define-macro but I could not figure
> out what. Sometimes one of them works, sometimes the other.
Well, my approach would be like this:
;; --------------------- File: mod-comp.scm
(use-modules (ice-9 syncase))
(define-syntax module
(syntax-rules ()
((module (a))
(define-module (a)))
((module (a ...))
(define-module (a ...)))))
;))
(define (glob fu)
(format #t "GLOB: ~A!\n" fu))
(export glob)
; ---------------------- File: a.scm
;; A sample module
(module (a))
(define (glob fu)
(format #t "GLOB: ~A!\n" fu))
(export glob)
And then:
ralf@calvin:/tmp$ guile -l mod-comp.scm
guile> (use-modules (a))
guile> (glob "Fubby")
GLOB: Fubby!
guile> ^D
Seems to work here ...
hth Ralf Mattes
> Peter Ivanyi
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-05-15 14:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-15 12:42 module system Dr. Peter Ivanyi
2003-05-15 14:00 ` rm
2003-05-15 13:20 ` Dr. Peter Ivanyi
2003-05-15 14:59 ` rm
-- strict thread matches above, loose matches on Subject: below --
2003-05-15 14:48 Dr. Peter Ivanyi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).