[m-rev.] Fast string library

Peter Schachte schachte at cs.mu.OZ.AU
Thu May 17 00:28:04 AEST 2001


On Wed, May 16, 2001 at 03:35:54AM -0700, Ralph Becket wrote:
> To make the typeclass-only idea work, we would presumably have to make
> every
> user defined type an instance and automatically provide default 
> implementations.

Right.  I believe that's happening now for unification and comparison, and
maybe printing.  Maybe others?

>  Moreover, we would have to restrict the declaration of
> instancehood for this case to the defining module.  Bleugh.

Why would that be?  I guess I don't understand how instance declaractions
for a type can be defined other than in the module that defines the type.
How can the compiler keep you from declaring the same type to be an instance
of the same class, with different method implementations, in different
source files?

But this doesn't seem so horrible to me.  Your smarter string type seems a
good example.  You really *want* to define its comparison method in the same
module.  Anywhere else would seem odd to me.  The "where comparison is"
approach has the same restriction, anyway.

The advantage of the generalization, if it can be implemented efficiently,
is that you could define your own operations that could be performed on any
type, but where certain types can define their own methods.  As soon as
"where comparison is" is implemented, someone will want "where printing is"
or "where binary_dump is" and "where binary_read is", or ....

-- 
Peter Schachte <schachte at cs.mu.OZ.AU>  Nearly all men can stand adversity,
http://www.cs.mu.oz.au/~schachte/      but if you want to test a man's
Phone:  +61 3 8344 9166                character, give him power.
Fax:    +61 3 9348 1184                    -- Abraham Lincoln 
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list