[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: possible bug while exporting generics
From: |
Ludovic Courtès |
Subject: |
Re: possible bug while exporting generics |
Date: |
Thu, 02 Aug 2007 15:10:39 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Hi,
(No need to post to both lists.)
schemer <address@hidden> writes:
> ;; ------------------------------
> ;; file a.scm
> (define-module (a)
> #:use-module (oop goops)
> #:duplicates merge-generics)
>
> (define-class <a> ()
> (a
> #:init-value 0
> #:getter /val))
>
> (export <a> /val)
>
> ;; -------------------
> ;; file ab.scm
> (define-module (ab)
> #:use-module (oop goops)
> #:use-module (a)
> #:use-module (ice-9 pretty-print)
> #:duplicates merge-generics)
>
> (define-class <ab> ()
> (ab
> #:init-value 0
> #:getter /val))
>
> (pretty-print (generic-function-methods /val))
>
> (export /val <ab>)
Guile's behavior is admittedly unclear, but your example is wrong:
module `(ab)' shouldn't export `/val' since it is just adding a new
method to the existing generic bound to `/val'. Thus it should either,
not export it, or just re-export it:
===File ~/tmp/guilish/ab.scm================================
;; -------------------
;; file ab.scm
(define-module (ab)
#:use-module (oop goops)
#:use-module (a)
#:use-module (ice-9 pretty-print))
(define-class <ab> ()
(ab
#:init-value 0
#:getter /val))
(pretty-print (generic-function-methods /val))
(export <ab>)
(re-export /val)
============================================================
This fixes the problem:
$ guile -L .
guile> (module-ref (resolve-module '(ab)) '/val)
(#<<accessor-method> (<ab>) b72cc200>
#<<accessor-method> (<a>) b72daf00>)
#<<generic> /val (2)>
Thanks,
Ludovic.