[m-dev.] for review: destructive changes to string.m

schachte at cs.mu.OZ.AU schachte at cs.mu.OZ.AU
Sat Nov 11 00:11:51 AEDT 2000


This'll probably be controversial, but what the heck...

On 10 Nov, Fergus Henderson wrote:
> On 10-Nov-2000, Michael Day <mikeday at corplink.com.au> wrote:
>> 
>> 	Added three new predicates, string__set, set_det and unsafe_set
>> 	that allow changing arbitrary characters in a string. These function
>> 	similarly to the corresponding index, index_det and unsafe_index
>> 	predicates. (Is set an appropriate name? Overloading index/3 with
>> 	index/4 is presumably a bad idea).
> 
> I suggest using `set_char' (and `set_char_det', `unsafe_set_char').
>
> It might be better to make those functions rather than predicates.

Perhaps it would be better to make the field access syntax work for
this?  Ie, define the right functions so that you can write something
like

	String ^ char(3)

to access the third (or fourth?) character of String and

	String ^ char(3) := 'a'

to replace that character with 'a'.  This makes the duality between
access and set clearer.  I forget the syntax/conventions for doing
this and am too lazy to look it up, but I think you just have to
define a 

       char(int,string) = char

function and a 

	'set char'(int,string,char) = string 

function, or something like that.


-- 
Peter Schachte                     The use of COBOL cripples the mind; its
mailto:schachte at cs.mu.OZ.AU        teaching should, therefore, be regarded
http://www.cs.mu.oz.au/~schachte/  as a criminal offense.
PGP: finger schachte at 128.250.37.3      -- E. W. Dijkstra 


--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list