From: Christopher Howard <christopher.howard@qlfiles.net>
To: guile-user@gnu.org
Subject: Re: Comparison operators for strings /and/ numbers?
Date: Mon, 18 Sep 2017 20:27:15 -0800 [thread overview]
Message-ID: <1505795235.14330.2.camel@qlfiles.net> (raw)
In-Reply-To: <87fuchxufg.fsf@fencepost.gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1797 bytes --]
On Thu, 2017-08-24 at 10:05 +0200, David Kastrup wrote:
> Christopher Howard <christopher.howard@qlfiles.net> 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.
>
> (use-modules (oop goops))
>
> (define-method (< (a <string>) . rest)
> (apply string<? a rest))
>
> (< "g" "b") ;; => #f
>
Forgive me for bring this thread back, but I just finished reading the
goops info manual...
My question, specifically: Suppose:
1) I use fn "<" in my module, as a goops generic, and then
2) somebody else "use"s my module in their module, and then
3) suppose they do a "define-method" to create another "<" for a new
datatype
4) they call a function in my module that uses "<"
Will that function call have access to the new method for that generic?
Background: This would obvious be very important in a module providing
a generic data structure (like a binary tree), where you would want to
compare keys using "<", but you wouldn't want to arbitrarily limit the
possible data types to what was defined in the module.
Or do I need to define an <ordered> class and expose that to my module
users? I'm thinking in terms like Data.Ord class from Haskell. (Java
folks would call it an "interface".)
--
https://qlfiles.net
https://emailselfdefense.fsf.org/en/
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2017-09-19 4:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 6:05 Comparison operators for strings /and/ numbers? Christopher Howard
2017-08-24 8:05 ` David Kastrup
2017-09-19 4:27 ` Christopher Howard [this message]
2017-08-24 8:29 ` Arne Babenhauserheide
2017-08-24 10:17 ` Ralf Mattes
2017-08-24 17:58 ` Arne Babenhauserheide
2017-08-24 13:31 ` Chris Vine
2017-08-24 13:41 ` Chris Vine
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=1505795235.14330.2.camel@qlfiles.net \
--to=christopher.howard@qlfiles.net \
--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).