unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jan Wedekind <jan@wedesoft.de>
To: "Kovacsics Róbert" <kovirobi@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: Modules and GOOPS
Date: Wed, 27 Jul 2016 20:44:04 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.2.11.1607272037170.20964@wedemob> (raw)
In-Reply-To: <CABPkNKmRUQ2WhdZoJgkxSquMSVVQRLEQ5WXEsnx0gKVbA4ArvA@mail.gmail.com>

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))


  reply	other threads:[~2016-07-27 19:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27 17:53 Modules and GOOPS Kovacsics Róbert
2016-07-27 19:44 ` Jan Wedekind [this message]
2016-07-28 22:36   ` David Pirotte
2016-07-28 21:14 ` David Pirotte
2016-07-29  5:17   ` David Pirotte
2016-07-29 17:00   ` Kovacsics Róbert
2016-07-29 18:00     ` Marko Rauhamaa
2016-07-31  3:59       ` David Pirotte
2016-07-31 10:44       ` Chris Vine
2016-07-31 16:38         ` Marko Rauhamaa
2016-07-31  2:35     ` David Pirotte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.11.1607272037170.20964@wedemob \
    --to=jan@wedesoft.de \
    --cc=guile-user@gnu.org \
    --cc=kovirobi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).