[m-dev.] Unicode support in Mercury

Peter Schachte schachte at csse.unimelb.edu.au
Wed May 11 11:33:38 AEST 2011


On 10/05/11 22:19, Matt Giuca wrote:

> characters, which is not much better. Peter Schachte's suggestion (to
> abstract the index type) would fix this by not letting you write such
> code in the first place, but then how could you go about chunking a
> string into large increments at all?

Abstracting the type does have the downside that it'll force you to (as you
really should) work out what operations make sense and are implementable.  For
example, you'd probably want to allow <, =<, >, and >= on the abstract type,
and they would work fine for the proposed implementation, as long as they're
only used to compare indices for the same string.  As for chunking a string,
you could always provide operations to return the difference between two
indices for a string in both bytes and characters, and operations to add a
certain number of characters and (at most) a certain number of bytes to an
index for a given string, returning a new index.  Together with a substring
operation that takes a string and two indices, this should do it.

-- 
Peter Schachte              Fallacies do not cease to be fallacies because
University of Melbourne     they become fashions.
schachte at unimelb.edu.au         -- G. K. Chesterton
www.cs.mu.oz.au/~schachte/
Phone: +61 3 8344 1338
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list