* new module directive? [was: Three real-life questions]
2004-04-09 11:32 ` Andy Wingo
@ 2004-04-13 16:33 ` Andreas Rottmann
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rottmann @ 2004-04-13 16:33 UTC (permalink / raw)
Andy Wingo <wingo@pobox.com> writes:
> Hi Michael,
>
> On Tue, 2004-04-06 at 13:01, Michael Burschik wrote:
>> 1. How should one export, or re-export modified generic functions?
>> Using :export seems to work as expected, although guile complains
>> about the use of deprecated features. Using :re-export gets rid of the
>> complaints, but does not seem to be documented in the guile manual. So
>> what is the correct way to handle generic functions in modules?
>
> If a module that you use supplies a binding, and you want that binding
> to be available for users of your module, you must re-export it. This
> applies to generics as well as other bindings. Lack of documentation on
> this is a bug, though!
>
The hairy thing is when you want to override (extend) a non-generic
with a generic. #:re-export won't work in this case and #:export gives
a warning. Example code:
;; export-test.scm
(define-module (export-test)
#:use-module (oop goops)
#:export (quit))
(define quit (ensure-generic quit))
(define-class <mainloop>)
(define-method (quit (loop <mainloop>))
;; some code here
loop)
Then, the extended quit works as expected:
ivanova:~/tmp/test% guile
guile> (use-modules (export-test) (oop goops))
Using `export' to re-export imported bindings is deprecated. Use `re-export' instead.
(You just re-exported `quit' from `(export-test)'.)
guile> (quit (make <mainloop>))
#<<mainloop> 80891a0>
guile> (quit 66)
ivanova:~/tmp/test% echo $?
66
I'd really like to see an #:override or somesuch module option that
doesn't warn in this case...
Andy
--
Andreas Rottmann | Rotty@ICQ | 118634484@ICQ | a.rottmann@gmx.at
http://yi.org/rotty | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62
The best way to accelerate a Windows machine is at 9.81 m/s^2
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: new module directive? [was: Three real-life questions]
@ 2004-04-16 6:06 Michael Burschik
2004-04-16 13:58 ` new module directive? Andreas Rottmann
0 siblings, 1 reply; 3+ messages in thread
From: Michael Burschik @ 2004-04-16 6:06 UTC (permalink / raw)
Andreas Rottmann says:
> The hairy thing is when you want to override (extend) a non-generic
> with a generic. #:re-export won't work in this case and #:export gives
> a warning.
This is pretty nasty, especially since #:re-export gives no indication of
not working, and I did not, in fact, notice that it does not. I extended
equal? with a generic and it seemed to work as expected when I used
#:re-export. Was this simply a coincidence, or is equal? generic anyway?
Regards
Michael Burschik
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: new module directive?
2004-04-16 6:06 new module directive? [was: Three real-life questions] Michael Burschik
@ 2004-04-16 13:58 ` Andreas Rottmann
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rottmann @ 2004-04-16 13:58 UTC (permalink / raw)
"Michael Burschik" <Burschik@lotto-berlin.de> writes:
> Andreas Rottmann says:
>
>> The hairy thing is when you want to override (extend) a non-generic
>> with a generic. #:re-export won't work in this case and #:export gives
>> a warning.
>
> This is pretty nasty, especially since #:re-export gives no indication of
> not working, and I did not, in fact, notice that it does not. I extended
> equal? with a generic and it seemed to work as expected when I used
> #:re-export. Was this simply a coincidence, or is equal? generic anyway?
>
As soon GOOPS is loaded, equal? is changed to a
"primitive-generic". IMHO, it would be nice if that would happen for
every procedure...
guile> equal?
#<primitive-procedure equal?>
guile> (use-modules (oop goops))
guile> equal?
#<primitive-generic equal?>
Andy
--
Andreas Rottmann | Rotty@ICQ | 118634484@ICQ | a.rottmann@gmx.at
http://yi.org/rotty | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62
Make free software, not war!
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-04-16 13:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-16 6:06 new module directive? [was: Three real-life questions] Michael Burschik
2004-04-16 13:58 ` new module directive? Andreas Rottmann
-- strict thread matches above, loose matches on Subject: below --
2004-04-06 12:01 Three real-life questions Michael Burschik
2004-04-09 11:32 ` Andy Wingo
2004-04-13 16:33 ` new module directive? [was: Three real-life questions] Andreas Rottmann
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).