[m-rev.] for review: mercury implementation of string.m

Ralph Becket rafe at cs.mu.OZ.AU
Mon Jun 17 15:32:43 AEST 2002


Simon Taylor, Saturday, 15 June 2002:
> 
> That's fine, but you've chosen the wrong primitives to base the rest
> of the operations on. Mercury strings are not lists. string__first_char
> is an unnatural operation for strings, and expressing algorithms which
> iterate over strings in terms of it will cause unacceptable inefficiency.

Couldn't agree more.
> 
> A better choice of basic operations would be string__alloc (this
> would allocate memory for a string given the length), string__length,
> string__unsafe_index and string__unsafe_set_char. Operations based
> on these primitives should be fairly close in efficiency to foreign
> code implementations (if not, we need to improve the compiler).

Some back-end languages do no have mutable strings.  Instead they supply
char buffer ADTs (e.g. C#'s StringBuilder class) which support (at
least) the operations you suggest.

My guess is that this would be a better approach all round.  I could
probably get something working using the existing foreign language code
in string.m in short order.  Yea/nay?

- Ralph
--------------------------------------------------------------------------
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