home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.scheme
- Path: sparky!uunet!brunix!brunix!mj
- From: mj@cs.brown.edu (Mark Johnson)
- Subject: Total ordering on scheme objects (Was Re: case sensitivity)
- Message-ID: <1992Nov6.171856.3414@cs.brown.edu>
- Sender: news@cs.brown.edu
- Organization: Brown University Department of Computer Science
- References: <1992Nov6.062357.8865@Informatik.TU-Muenchen.DE> <1de4rhINNn4u@agate.berkeley.edu>
- Date: Fri, 6 Nov 1992 17:18:56 GMT
- Lines: 40
-
- > string->symbol is a concession to people with unusual needs. The reason
- > it doesn't follow the usual rules for symbols is that it exists precisely
- > as a mechanism to escape from those rules. Using string->symbol is
- > cheating, sort of like using goto in some other languages.
-
- I disagree. I use string->symbol as a way of defining a total ordering
- on symbols (and extend it to a total ordering on all Scheme objects).
- Lots of algorithms exploit an ability to compare keys. For example,
- AVL trees can be used to implement an associator that runs in O(ln n)
- time per insertion/look-up, but they require a total ordering on keys.
-
- I think one of the most insightful innovations of the Prolog designers
- was to include a general predicate called compare, which implements a
- total ordering on all Prolog objects. With it, you can write
- associator and set-manipulation utilities that are both fast and
- completely general.
-
- I would like to suggest that Scheme too might also be extended to
- include a function
-
- (compare <entity1> <entity2>)
-
- that returns one of the three symbols <, =, or >, depending on the
- relationship between <entity1> and <entity2> in the total ordering,
- where = indicates identity in the eq? sense. All that needs to be
- specified in the standard is that compare defines a total ordering.
-
- I don't have much hope that anything like this will actually make
- it into the standard -- you'd actually have to be interested in
- using Scheme for real problems to find something like this useful. :-)
- But until it does, I'll have a very real need for symbol->string !.
-
- Mark
-
-
-
-
- Mark Johnson
- Cognitive Science, Box 1978
- Brown University
-