[m-rev.] Minor addition to string.m

Peter Moulder pmoulder at csse.monash.edu.au
Wed Jan 29 15:58:05 AEDT 2003


On Wed, Jan 29, 2003 at 03:33:21PM +1100, Simon Taylor wrote:

> > 	Added function chomp/1.
> 
> How about `remove_trailing_newline', or even better a more
> general `remove_trailing_char'.

A disadvantage of those names is that they are inconsistent with
"remove_suffix", which is semidet, whereas chomp succeeds (as an
identity transform) if the string does not end in the specified char.

Alternatives are `maybe_remove...' or `remove..._if_present', or (by
analagy with set.remove/set.delete) `delete_trailing_...'.

Personally, I'm content with chomp.  For those that don't know, the name
comes from the perl function of the same name.  [In Perl, the string
that is conditionally removed is determined by the value of the
record-separator variable $/ (a.k.a. $RS or $INPUT_RECORD_SEPARATOR).]

pjm.
--------------------------------------------------------------------------
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