From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.user Subject: Re: goops and equal? Date: Mon, 10 Nov 2014 21:03:14 +0800 Message-ID: References: <87wq73ciwb.fsf@drakenvlieg.flower> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3eeee1c3d65050780c971 X-Trace: ger.gmane.org 1415624620 32200 80.91.229.3 (10 Nov 2014 13:03:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Nov 2014 13:03:40 +0000 (UTC) Cc: Guile User To: Jan Nieuwenhuizen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Nov 10 14:03:36 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xnod5-00077H-SB for guile-user@m.gmane.org; Mon, 10 Nov 2014 14:03:36 +0100 Original-Received: from localhost ([::1]:43032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnod5-00058F-7Q for guile-user@m.gmane.org; Mon, 10 Nov 2014 08:03:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnocu-000583-2B for guile-user@gnu.org; Mon, 10 Nov 2014 08:03:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xnocn-0001hl-U8 for guile-user@gnu.org; Mon, 10 Nov 2014 08:03:24 -0500 Original-Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:42008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xnocn-0001fs-C8; Mon, 10 Nov 2014 08:03:17 -0500 Original-Received: by mail-la0-f45.google.com with SMTP id pn19so7661741lab.18 for ; Mon, 10 Nov 2014 05:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=4HC+xplDzgFCKcu2T+7nYtk0CUysCAzLjFkBJ2gGSRA=; b=hFlh6R2RK23rTMrVWIdvjnZyRRmj8CloKeNx4q33YZKQfeRqjJAkrXAjs0+YBxTFYs TWvhBYOoy9wz/PylE2EarRfFtxph6ceFRAUNVI1nLLSrgsUJLE37JN3KARu4uTIQxdtN y1HLcKgqzvYJAnQ6noxUxUxWNQgnxGSMGARzXPyCsOKhf6zJa/JoNtv4r0HycnM9CUQY /k0JFpiv3ZtACbF47mqVOST7c6aimb2HncQwsLD61cA3ES4VRrxEFYNngxIhhTi1WBNY bjZz0b37LGMuvoFygkHf2xp6rSZZ4cqJy5q1z8ZLpVHzrq51qSxPxpN/vqV2OuzqiP/G hpQA== X-Received: by 10.112.54.162 with SMTP id k2mr29101863lbp.63.1415624594825; Mon, 10 Nov 2014 05:03:14 -0800 (PST) Original-Received: by 10.152.161.232 with HTTP; Mon, 10 Nov 2014 05:03:14 -0800 (PST) Original-Received: by 10.152.161.232 with HTTP; Mon, 10 Nov 2014 05:03:14 -0800 (PST) In-Reply-To: <87wq73ciwb.fsf@drakenvlieg.flower> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22d X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11630 Archived-At: --001a11c3eeee1c3d65050780c971 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think you have to define your specific certain-class-equal? So does record-type. 2014=E5=B9=B411=E6=9C=8810=E6=97=A5 =E4=B8=8B=E5=8D=888:58=E4=BA=8E "Jan N= ieuwenhuizen" =E5=86=99=E9=81=93=EF=BC=9A > Hi, > > In the example below, my implementation of equal? is only being > used if both types are the same. That surprised me; the manual > says equal? becomes a generic and for normal generics this works > as I expect. > > How do I get the magic equal? to do what show the same result as the > simple generic type-equal? > > And also, do we want such surprises? > > Greetings, > Jan > > (read-set! keywords 'prefix) > (use-modules (oop goops)) > > (define-class () > (name :accessor .name :init-value #f :init-keyword :name)) > > (define-method (equal? (a ) (b )) > (display "equal?\n") > (eq? (.name a) (.name b))) > > (define-method (equal? (a ) (b )) > (display "equal?\n") > (eq? (.name a) b)) > > (define-method (type-equal? (a ) (b )) > (display "equal?\n") > (eq? (.name a) b)) > > (format #t "equal?: ~a\n" (equal? (make :name 'a) (make > :name 'a))) > (newline) > (format #t "equal?: ~a\n" (equal? (make :name 'a) 'a)) > (newline) > (format #t "type-equal?: ~a\n" (type-equal? (make :name 'a) 'a)) > (newline) > > > -- > Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org > Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.= nl > > --001a11c3eeee1c3d65050780c971 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I think you have to define your specific certain-class-equal= ?
So does record-type.

2014=E5=B9=B411=E6=9C=8810=E6=97=A5 =E4=B8=8B=E5= =8D=888:58=E4=BA=8E "Jan Nieuwenhuizen" <janneke@gnu.org>=E5=86=99=E9=81=93=EF=BC=9A
Hi,

In the example below, my implementation of equal? is only being
used if both types are the same.=C2=A0 That surprised me; the manual
says equal? becomes a generic and for normal generics this works
as I expect.

How do I get the magic equal? to do what show the same result as the
simple generic type-equal?

And also, do we want such surprises?

Greetings,
Jan

(read-set! keywords 'prefix)
(use-modules (oop goops))

(define-class <type> ()
=C2=A0 (name :accessor .name :init-value #f :init-keyword :name))

(define-method (equal? (a <type>) (b <type>))
=C2=A0 (display "<type>equal?\n")
=C2=A0 (eq? (.name a) (.name b)))

(define-method (equal? (a <type>) (b <symbol>))
=C2=A0 (display "<type0>equal?\n")
=C2=A0 (eq? (.name a) b))

(define-method (type-equal? (a <type>) (b <symbol>))
=C2=A0 (display "<type1>equal?\n")
=C2=A0 (eq? (.name a) b))

(format #t "equal?: ~a\n" (equal? (make <type> :name 'a= ) (make <type> :name 'a)))
(newline)
(format #t "equal?: ~a\n" (equal? (make <type> :name 'a= ) 'a))
(newline)
(format #t "type-equal?: ~a\n" (type-equal? (make <type> :n= ame 'a) 'a))
(newline)


--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http= ://lilypond.org
Freelance IT http://Jo= yofSource.com | Avatar=C2=AE=C2=A0 http://AvatarAcademy.nl

--001a11c3eeee1c3d65050780c971--