[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module directive? [was: Three real-life questions]
From: |
Andreas Rottmann |
Subject: |
new module directive? [was: Three real-life questions] |
Date: |
Tue, 13 Apr 2004 18:33:33 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) |
Andy Wingo <address@hidden> 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 | address@hidden | address@hidden | address@hidden
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