Skip to content

Instantly share code, notes, and snippets.

@KoviRobi
Last active July 27, 2016 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KoviRobi/e708da67d38f1a505293742c9d2647e9 to your computer and use it in GitHub Desktop.
Save KoviRobi/e708da67d38f1a505293742c9d2647e9 to your computer and use it in GitHub Desktop.
(define-module (mbe a)
#:use-module (oop goops)
#:export (x y))
(define-generic x)
(define-generic y)
(define-module (mbe b1)
#:use-module (oop goops)
#:use-module (mbe a)
#:export (<a> y))
(define-class <a> ())
(define-method (y (a <a>))
(x a))
(define-module (mbe c1)
#:use-module (oop goops)
#:use-module (mbe a)
#:use-module (mbe b1)
#:export (<b> x))
(define-class <b> (<a>))
(define-method (x (b <b>))
'b)
(define-module (mbe test)
#:use-module (oop goops)
#:use-module (mbe a)
#:use-module (mbe b1)
#:use-module (mbe c1)
#:duplicates (merge-generics))
(y (make <b>))
@KoviRobi
Copy link
Author

KoviRobi commented Jul 27, 2016

When I put each module in their respective files, so that they are in %load-path, and 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>)

When I don't use separate modules, but just type the following in at the repl, it works

(use-modules (oop goops))

(define-class <a> ())

(define-generic x)
(define-generic y)

(define-method (y (a <a>))
  (display (x a)))

(define-class <b> (<a>))

(define-method (x (b <b>))
  'b)

(y (make <b>))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment