guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [goops] adding a number class with generic methods


From: Marco Maggi
Subject: Re: [goops] adding a number class with generic methods
Date: Thu, 4 May 2006 21:13:15 +0200

"Neil Jerram" wrote:
>"Marco Maggi" <address@hidden> writes:
> "address@hidden" wrote:
>>  I do not understand why  the first solution does not work;
>>I've tried different combinations  of functions but there is
>>something I am missing.
>
> Damn... it seems to work if I do not EXPORT the generic
> methods.
>
>You mean if you remove the "(export =)" line?

Yes, with the following and no EXPORT invocation
it works.

(define-macro (make-comparison-operator class name func)
  `(begin
     (define-method (,name (a ,class) (b ,class))
       (,func (slot-ref a 'n) (slot-ref b 'n)))

     (define-method (,name (a ,class) (b <real>))
       (,func (slot-ref a 'n) (usable->mpfr b)))

     (define-method (,name (a <real>) (b ,class))
       (,func (usable->mpfr a) (slot-ref b 'n)))))

(make-comparison-operator <mpfr> = mpfr-equal?)


--
Marco Maggi






reply via email to

[Prev in Thread] Current Thread [Next in Thread]