[m-rev.] diff: string splitting routines to string.m
Ondrej Bojar
obo at cuni.cz
Fri Feb 2 11:48:50 AEDT 2007
Ralph Becket wrote:
> We already have the pred string.remove_suffix. I would rather you added
> a function version of string.remove_suffix (`chomp' isn't a good name,
> even if it's used in millions of Perl scripts).
remove_suffix_if_present would be better?
or
remove_suffix_det -- I don't like this one
or
chomp_suffix
I just think it needs to be different from remove_suffix (semidet), but
the name should not suggest raising an exception (as _det functions tend
to do).
>>+:- func string.split_at_separator(pred(char), string) = list(string).
>>+:- mode string.split_at_separator(pred(in) is semidet, in) = out is det.
> Is this generally useful enough to go in the string module? (I have no
> idea one way or the other.)
You have string.words_separator, which is unfortunately absolutely
useless for tab-delimited input lines, because it removes consecutive
tabs... split_at_{char,separator} fix that.
>>+ % string.split_at_string("|||", "|||fld2|||fld3")
>>+ % = ["", "fld2", [fld3"]
> What does string.split_at_string("aaa", "xaaaa aaaaax aaa x" return?
["x", "a ", "aax ", " x"]
Proposed comment:
Always the first match of Separator is used to break the String, for
example:
string.split_at_string("aa", "xaaayaaaz") = ["x", "ay", "az"]
> Is this useful enough to go in string.m?
Depends on the type of input you tend to process often.
I don't know your general policy. My policy would be: given any
super-nifty function (with a testcase provided), if a reasonable number
of programmers agree on the module it should go in and they understand
well what it does given the name it should get, I'd put it in and not
ask how often will they use it.
> In general you should adhere to the coding style used in the module you
> are editing.
I was already trying to :-( But I'll fix all other places you mentioned
or I can find.
O.
--
Ondrej Bojar (mailto:obo at cuni.cz)
http://www.cuni.cz/~obo
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list