guile-user
[Top][All Lists]
Advanced

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

Re: Comparison operators for strings /and/ numbers?


From: Arne Babenhauserheide
Subject: Re: Comparison operators for strings /and/ numbers?
Date: Thu, 24 Aug 2017 19:58:42 +0200

Ralf Mattes <address@hidden> writes:

> On Thu, Aug 24, 2017 at 10:29:41AM +0200, Arne Babenhauserheide wrote:
>> Hi Christopher,
>> 
>> You can use GOOPS to make them generic:
>> 
>> > (import (oop goops))
>> > (< "a" "b")
>
> That's not what David suggested.

No, it is not. I wrote my reply before I saw his.

>> <unnamed port>:3:0: <unnamed port>:3:0: In procedure <: Wrong type argument 
>> in position 1: "a"
>> 
>> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
>> [1]> (define-method (< (a <string>) (b <string>)) (string<? a b))
>> [1]> (< "a" "b")
>> $1 = #t
>> 
>> For some functions you might need to call (define-generic <function>)
>> before this (you’ll notice because define-method will signal an error).
>
> Is that still the case?

Yes. Try:

> (import (oop goops))
> (define-method (list (a <string>)))
ERROR: In procedure scm-error:
ERROR: #<procedure list _> is not a valid generic function

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

Attachment: signature.asc
Description: PGP signature


reply via email to

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