From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ralf Mattes Newsgroups: gmane.lisp.guile.user Subject: Re: Comparison operators for strings /and/ numbers? Date: Thu, 24 Aug 2017 12:17:14 +0200 Message-ID: <20170824101714.cvb6mhuaq44rqyp3@seid-online.de> References: <1503554737.21598.3.camel@qlfiles.net> <87378hjrhn.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1503569895 28765 195.159.176.226 (24 Aug 2017 10:18:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 Aug 2017 10:18:15 +0000 (UTC) User-Agent: NeoMutt/20170609 (1.8.3) Cc: Guile User Mailing List To: Arne Babenhauserheide Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Aug 24 12:18:10 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkpD2-0006VK-Dh for guile-user@m.gmane.org; Thu, 24 Aug 2017 12:17:56 +0200 Original-Received: from localhost ([::1]:47570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpD8-0008Uk-Oy for guile-user@m.gmane.org; Thu, 24 Aug 2017 06:18:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkpCT-0008NO-0T for guile-user@gnu.org; Thu, 24 Aug 2017 06:17:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkpCP-0006E5-RA for guile-user@gnu.org; Thu, 24 Aug 2017 06:17:20 -0400 Original-Received: from mail.seid-online.de ([5.199.139.24]:59962) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkpCP-0006DB-Kf for guile-user@gnu.org; Thu, 24 Aug 2017 06:17:17 -0400 Original-Received: from ralf by mail.seid-online.de with local (Exim 4.89) (envelope-from ) id 1dkpCM-0000WN-In; Thu, 24 Aug 2017 12:17:14 +0200 Content-Disposition: inline In-Reply-To: <87378hjrhn.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.199.139.24 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.user:14052 Archived-At: 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. Of course you still need to define the method specialized on strings. > :3:0: :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 ) (b )) (string [1]> (< "a" "b") > $1 = #t > > For some functions you might need to call (define-generic ) > before this (you’ll notice because define-method will signal an error). Is that still the case? IIRC this was true for Guile 1 where you needed to "redeclare" build-in functions as generic, but from what I see Guile2 automatically generates the appropriate generic functions. This is pretty much how Common Lisp handles defmethod without a matching defgeneric (but in CL you aren't allowed to transform a function from CL into a generic). Cheers, Ralf Mattes > Best wishes, > Arne > > Christopher Howard writes: > > > Hi, in another lisp I have been working with, it has <, >, and == > > (structure equality) operators which can take string arguments, number > > arguments, or a mixture of both. But it seems in guile that there are > > separate comparison operators for strings and for numbers. This makes > > sense but is not very convenient for my present purpose. Is there some > > other guile operators or extension operators that will handle both? I > > could make some I'm sure, but I don't want to reinvent the wheel. > > -- > Unpolitisch sein > heißt politisch sein > ohne es zu merken