[wx-dev] Re: wxArray::Join and wxArray::Split
Armel Asselin
asselin.armel at wanadoo.fr
Sun Jan 21 13:49:02 PST 2007
> Hi,
> little ping about this message (it could get lost in the others msg of
> this thread maybe)...
>
> Francesco Montorsi ha scritto:
>> Armel Asselin ha scritto:
>>>> AA> > I don't understand why should you do this, sorry. Join() should
>>>> be a
>>>> AA> > simple and safe function. And being safe is more important that
>>>> being
>>>> AA> > suitable for some esoteric uses or compatible with ECMAScript.
>>>> AA> I really do not see in which way it is less safe.
>>>>
>>>> Because it makes it very easy to get wrong results.
>>> just stating "it's less safe because it's less safe" is not what I call
>>> an argument. letting choice is just giving consciousness to the
>>> programmer, not making things less safe.
>> I agree with Armel: give the choice to the programmer.
>> If we keep the '\0'-disable-escaping feature _but_ we make
>> the default escape character be '\\' then only the programmers which _do_
>> know what are doing will use '\0' as escape char to disable escaping.
>>
>> If this is well documented and the programmer still uses '\0' and then
>> complains that Splitting() the string back does not return the same
>> thing, then that's not bad API design but rather a problem with that
>> programmer :)
>>
>> As I mentioned in the patch tracker:
>>
>> https://sourceforge.net/tracker/?func=detail&atid=309863&aid=1638950&group_id=9863
>> (I'm unsure if I should reply to this issue here or there), I think that
>> in some situations it can be very useful to not escape the separators in
>> wxJoin() since you're not interested to use wxSplit() with the result
>> later.
>>
>> A clear example is the wxLogBuffer::GetString() function: the resulted
>> string needs to be typically shown to the user in some way (through a log
>> file, a message box or whatever: log messages are for humans anyway) and
>> the user does not want to see escaped newlines!
>> It doesn't matter if a newline was separing two different log messages or
>> was part of a single newline...
>>
>> Francesco
your example is indeed a situation where I use a Join like of my own,
without escaping.
IMHO this is a good example.
Armel
More information about the wx-dev
mailing list