[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Modules and GOOPS
From: |
Jan Wedekind |
Subject: |
Re: Modules and GOOPS |
Date: |
Wed, 27 Jul 2016 20:44:04 +0100 (BST) |
User-agent: |
Alpine 2.11 (DEB 23 2013-08-11) |
On Wed, 27 Jul 2016, Kovacsics Róbert wrote:
Hello!
I have trouble with getting GOOPS and modules to co-operate. What I am
trying to do is to have 'A subclass B' where A is something akin to an
abstract class, that is it has generic "x" for which it provides no
implementation. This is my minimum broken example:
; <mbe/a.scm>=
(define-module (mbe a)
#:use-module (oop goops)
#:export (<a> x y))
(define-class <a> ())
(define-generic x)
(define-generic y)
(define-method (y (a <a>))
(display (x a)))
; <mbe/b.scm>=
(define-module (mbe b)
#:use-module (oop goops)
#:use-module (mbe a)
#:export (<b> x))
(define-class <b> (<a>))
(define-method (x (b <b>))
'b)
; <mbe/test.scm>=
(define-module (mbe test)
#:use-module (oop goops)
#:use-module (mbe a)
#:use-module (mbe b)
#:duplicates (merge-generics))
(y (make <b>))
and when I type "(use-modules (mbe test))" in guile, I get
While compiling expression:
ERROR: No applicable method for #<<generic> x (0)> in call (x #<<b> 23ccdd0>)
(which shows that the generic function "x" has no implementation as
far as I can work it out, due to accessibility. When I don't use
separate modules, it works.)
Am I using the right sort of approach? I was thinking modules, for
extensibility.
Having mbe/b.scm *not* export "x" works but I am not sure whether that is
the solution you are looking for:
; <mbe/a.scm>=
(define-module (mbe a)
#:use-module (oop goops)
#:export (<a> x y))
(define-class <a> ())
(define-generic x)
(define-generic y)
(define-method (y (a <a>))
(display (x a)))
; <mbe/b.scm>=
(define-module (mbe b)
#:use-module (oop goops)
#:use-module (mbe a)
#:export (<b>))
(define-class <b> (<a>))
(define-method (x (b <b>))
'b)
; <mbe/test.scm>=
(define-module (mbe test)
#:use-module (oop goops)
#:use-module (mbe a)
#:use-module (mbe b)
#:duplicates (merge-generics))
(y (make <b>))
Has anybody managed to get the "merge-generics" handler to work? I used to
have this in my $HOME/.guile configuration but it didn't seem to have any
effect:
(default-duplicate-binding-handler '(merge-generics replace warn-override-core
warn last))