From: ludo@gnu.org (Ludovic Courtès)
To: Dmitry Bogatov <KAction@gnu.org>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Goops generic-functions and srfi-64 tests
Date: Sun, 23 Nov 2014 18:20:03 +0100 [thread overview]
Message-ID: <871total6k.fsf@gnu.org> (raw)
In-Reply-To: <20141123072759.GA3444@self> (Dmitry Bogatov's message of "Sun, 23 Nov 2014 10:27:59 +0300")
Dmitry Bogatov <KAction@gnu.org> skribis:
> (define-method (equal? x y)
> ((@ (guile) equal?) x y))
This really shouldn’t be needed, and I would even expect it to lead to
infinite recursion actually.
> (define-method (equal? (this <object>) (other <object>))
> (let* ((class_ (class-of this))
> (slots (map car (class-slots class_))))
> (define (slot-values instance)
> (map (cute slot-ref instance <>) slots))
> (if (eq? class_ (class-of other))
> (false-if-exception (equal? (slot-values this) (slot-values other)))
> #f)))
>
> I do not know, why first one `equal?` is needed, but otherwise guile
> complained, that no method is present to compare two lists.
Hmm, simply doing the following works for me:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(oop goops)
scheme@(guile-user)> (define-method (equal? (a <object>) (b <object>)) 42)
scheme@(guile-user)> (equal? 1 2)
$1 = #f
scheme@(guile-user)> (equal? <class> <string>)
$2 = 42
--8<---------------cut here---------------end--------------->8---
> Interesting enough, I created simple module, and behaves as it should.
> Maybe you have some wild guess about class being defined not via macro?
What do you mean by “simple module”?
Thanks,
Ludo’.
next prev parent reply other threads:[~2014-11-23 17:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-22 12:48 Goops generic-functions and srfi-64 tests KAction
2014-11-22 21:24 ` Ludovic Courtès
2014-11-23 7:27 ` Dmitry Bogatov
2014-11-23 17:20 ` Ludovic Courtès [this message]
2014-11-23 18:56 ` Dmitry Bogatov
[not found] <mailman.91.1416675626.13049.guile-user@gnu.org>
2014-11-23 13:07 ` Daniel Llorens
2014-11-23 13:47 ` Taylan Ulrich Bayırlı/Kammer
2014-11-23 13:56 ` Daniel Llorens
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=871total6k.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=KAction@gnu.org \
--cc=guile-user@gnu.org \
/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).