* Guile module system problem
@ 2009-01-20 10:18 Panicz Maciej Godek
2009-01-20 12:15 ` Neil Jerram
0 siblings, 1 reply; 7+ messages in thread
From: Panicz Maciej Godek @ 2009-01-20 10:18 UTC (permalink / raw)
To: guile-user
Hi, I've been trying to move some of my code into
loadable guile modules. I made a directory "modules"
in my project tree and moved the module in there.
I ran into some problems. Here's how I load the
module:
(set! %load-path (cons "." %load-path))
(load-module (modules goose))
At this point, guile signals an error (unbound variable).
Here's how the module looks like:
(define-module (modules goose)
:use-module (oop goops)
:replace (slot-ref))
(define slot-ref (make-procedure-with-setter slot-ref slot-set!))
And at this point guile complains that slot-ref is unbound.
I've been trying several combinations, like inserting
(use-modules (oop goops)) before the redefinition,
but the error seems to be imvunerable to this.
Regards
M
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Guile module system problem
2009-01-20 10:18 Guile module system problem Panicz Maciej Godek
@ 2009-01-20 12:15 ` Neil Jerram
2009-01-20 13:07 ` Panicz Maciej Godek
0 siblings, 1 reply; 7+ messages in thread
From: Neil Jerram @ 2009-01-20 12:15 UTC (permalink / raw)
To: Panicz Maciej Godek; +Cc: guile-user
2009/1/20 Panicz Maciej Godek <godek.maciek@gmail.com>:
> Hi, I've been trying to move some of my code into
> loadable guile modules. I made a directory "modules"
> in my project tree and moved the module in there.
>
> I ran into some problems. Here's how I load the
> module:
> (set! %load-path (cons "." %load-path))
> (load-module (modules goose))
> At this point, guile signals an error (unbound variable).
Please try `use-modules' instead of `load-module'.
Neil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Guile module system problem
2009-01-20 12:15 ` Neil Jerram
@ 2009-01-20 13:07 ` Panicz Maciej Godek
2009-01-20 16:52 ` Panicz Maciej Godek
0 siblings, 1 reply; 7+ messages in thread
From: Panicz Maciej Godek @ 2009-01-20 13:07 UTC (permalink / raw)
To: Neil Jerram; +Cc: guile-user
>> Hi, I've been trying to move some of my code into
>> loadable guile modules. I made a directory "modules"
>> in my project tree and moved the module in there.
>>
>> I ran into some problems. Here's how I load the
>> module:
>> (set! %load-path (cons "." %load-path))
>> (load-module (modules goose))
>> At this point, guile signals an error (unbound variable).
>
> Please try `use-modules' instead of `load-module'.
Well, I actually did that, I just made a mistake retyping
the code to the e-mail.
Eventually I have found the reason for this weird behavior:
since the slot-ref is present in the module's replace list,
it doesn't get exported from the goops module.
The solution is to refer to the goops's slot-ref function
in some other way (perhaps using the @ operator)
Thanks
M.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Guile module system problem
2009-01-20 13:07 ` Panicz Maciej Godek
@ 2009-01-20 16:52 ` Panicz Maciej Godek
2009-01-21 16:55 ` Ludovic Courtès
0 siblings, 1 reply; 7+ messages in thread
From: Panicz Maciej Godek @ 2009-01-20 16:52 UTC (permalink / raw)
To: Neil Jerram; +Cc: guile-user
> The solution is to refer to the goops's slot-ref function
> in some other way (perhaps using the @ operator)
Yet it's still not working. Now the module looks more or less
like this:
(define-module (modules goose)
:use-module (oop goops)
:replace (slot-ref))
(define slot-ref (make-procedure-with-setter (@ (oop goops) slot-ref)
slot-set!))
and the error I get when I try to use that module, is:
ERROR: invalid syntax #<variable 7fd6dd0ca610 value:
#<primitive-procedure slot-ref>>
What is wrong?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Guile module system problem
2009-01-20 16:52 ` Panicz Maciej Godek
@ 2009-01-21 16:55 ` Ludovic Courtès
2009-01-21 17:51 ` Panicz Maciej Godek
0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2009-01-21 16:55 UTC (permalink / raw)
To: guile-user
Hi,
"Panicz Maciej Godek" <godek.maciek@gmail.com> writes:
> Yet it's still not working. Now the module looks more or less
> like this:
> (define-module (modules goose)
> :use-module (oop goops)
> :replace (slot-ref))
>
> (define slot-ref (make-procedure-with-setter (@ (oop goops) slot-ref)
> slot-set!))
>
> and the error I get when I try to use that module, is:
> ERROR: invalid syntax #<variable 7fd6dd0ca610 value:
> #<primitive-procedure slot-ref>>
It works fine here with Guile 1.9 (`master'). I would expect it to work
as well with 1.8. Which version are you using?
Can you check whether evaluating the code above actually works
(directly, i.e., not via `(use-modules (modules goose))')?
Thanks,
Ludo'.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Guile module system problem
2009-01-21 16:55 ` Ludovic Courtès
@ 2009-01-21 17:51 ` Panicz Maciej Godek
2009-02-05 22:18 ` Neil Jerram
0 siblings, 1 reply; 7+ messages in thread
From: Panicz Maciej Godek @ 2009-01-21 17:51 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guile-user
Yellu :)
>> Yet it's still not working. Now the module looks more or less
>> like this:
>> (define-module (modules goose)
>> :use-module (oop goops)
>> :replace (slot-ref))
>>
>> (define slot-ref (make-procedure-with-setter (@ (oop goops) slot-ref)
>> slot-set!))
>>
>> and the error I get when I try to use that module, is:
>> ERROR: invalid syntax #<variable 7fd6dd0ca610 value:
>> #<primitive-procedure slot-ref>>
>
> It works fine here with Guile 1.9 (`master'). I would expect it to work
> as well with 1.8. Which version are you using?
I'm using 1.8.3 (from ubuntu repository)
> Can you check whether evaluating the code above actually works
> (directly, i.e., not via `(use-modules (modules goose))')?
Yes, when I'm evaluating it directly, everything works just fine.
I've found a possible reason, though. I didn't write that in
the module definition I also use syntax from (ice-9 syncase),
so it actually looks more like this:
(define-module (modules goose)
:use-syntax (ice-9 syncase)
:use-module (oop goops)
:replace (slot-ref))
Now you should get the error right :)
(sorry for this understatement)
When I place (use-syntax (ice-9 syncase)) *after* the
slot-ref definition, it seems to work well.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Guile module system problem
2009-01-21 17:51 ` Panicz Maciej Godek
@ 2009-02-05 22:18 ` Neil Jerram
0 siblings, 0 replies; 7+ messages in thread
From: Neil Jerram @ 2009-02-05 22:18 UTC (permalink / raw)
To: Panicz Maciej Godek; +Cc: Ludovic Courtès, guile-user, Guile Development
[-- Attachment #1: Type: text/plain, Size: 933 bytes --]
Panicz Maciej Godek <godek.maciek@gmail.com> writes:
>>> (define slot-ref (make-procedure-with-setter (@ (oop goops) slot-ref)
>>> slot-set!))
>>>
>>> and the error I get when I try to use that module, is:
>>> ERROR: invalid syntax #<variable 7fd6dd0ca610 value:
>>> #<primitive-procedure slot-ref>>
> I've found a possible reason, though. I didn't write that in
> the module definition I also use syntax from (ice-9 syncase),
> so it actually looks more like this:
> (define-module (modules goose)
> :use-syntax (ice-9 syncase)
> :use-module (oop goops)
> :replace (slot-ref))
>
> Now you should get the error right :)
> (sorry for this understatement)
>
> When I place (use-syntax (ice-9 syncase)) *after* the
> slot-ref definition, it seems to work well.
I have a fix for this, which I think is correct. (Not 100% sure, as
syncase is pretty tricky.) Please let me know if you have any
comments.
Regards,
Neil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Allow-to-work-with-ice-9-syncase.patch --]
[-- Type: text/x-diff, Size: 2392 bytes --]
From f8d80072759961eaecfa95e4f9446a5dc1016ca8 Mon Sep 17 00:00:00 2001
From: Neil Jerram <neil@ossau.uklinux.net>
Date: Thu, 5 Feb 2009 22:11:26 +0000
Subject: [PATCH] Allow @ to work with (ice-9 syncase)
(Reported by Panicz Maciej Godek.)
* test-suite/tests/syncase.test ("@ works with syncase"): New test.
* ice-9/syncase.scm (guile-macro): When a Guile macro transformer
produces a variable, don't pass it through sc-expand.
---
NEWS | 7 +++++++
THANKS | 1 +
ice-9/syncase.scm | 8 +++++---
test-suite/tests/syncase.test | 3 +++
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 71e9dc0..f3362ce 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,13 @@ Changes in 1.8.7 (since 1.8.6)
** Fix build problem when scm_t_timespec is different from struct timespec
** Fix build when compiled with -Wundef -Werror
+** Allow @ macro to work with (ice-9 syncase)
+
+Previously, use of the @ macro in a module whose code is being
+transformed by (ice-9 syncase) would cause an "Invalid syntax" error.
+Now it works as you would expect (giving the value of the specified
+module binding).
+
\f
Changes in 1.8.6 (since 1.8.5)
diff --git a/THANKS b/THANKS
index feafc12..84c957b 100644
--- a/THANKS
+++ b/THANKS
@@ -41,6 +41,7 @@ For fixes or providing information which led to a fix:
Peter Gavin
Eric Gillespie, Jr
Didier Godefroy
+ Panicz Maciej Godek
John Goerzen
Mike Gran
Szavai Gyula
diff --git a/ice-9/syncase.scm b/ice-9/syncase.scm
index 6ee4d16..39cf273 100644
--- a/ice-9/syncase.scm
+++ b/ice-9/syncase.scm
@@ -146,9 +146,11 @@
(let ((e ((macro-transformer m)
e
(append r (list eval-closure)))))
- (if (null? r)
- (sc-expand e)
- (sc-chi e r w))))))))))
+ (if (variable? e)
+ e
+ (if (null? r)
+ (sc-expand e)
+ (sc-chi e r w)))))))))))
(define generated-symbols (make-weak-key-hash-table 1019))
diff --git a/test-suite/tests/syncase.test b/test-suite/tests/syncase.test
index 1184f7b..c681fc3 100644
--- a/test-suite/tests/syncase.test
+++ b/test-suite/tests/syncase.test
@@ -34,3 +34,6 @@
(pass-if "basic syncase macro"
(= (plus 1 2 3) (+ 1 2 3)))
+
+(pass-if "@ works with syncase"
+ (eq? run-test (@ (test-suite lib) run-test)))
--
1.5.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-02-05 22:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20 10:18 Guile module system problem Panicz Maciej Godek
2009-01-20 12:15 ` Neil Jerram
2009-01-20 13:07 ` Panicz Maciej Godek
2009-01-20 16:52 ` Panicz Maciej Godek
2009-01-21 16:55 ` Ludovic Courtès
2009-01-21 17:51 ` Panicz Maciej Godek
2009-02-05 22:18 ` Neil Jerram
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).