perlmonger: (pete)
perlmonger ([personal profile] perlmonger) wrote2008-01-11 05:15 pm
Entry tags:

pass me another split, sergeant, this one's elfed

[Poll #1119627]

[ ETA that this is an abstract question, not an invitation for a language war, though go ahead and have one if you must ]

[identity profile] spride.livejournal.com 2008-01-12 01:26 am (UTC)(link)
It should throw an exception which you should handle.
ext_17706: (Default)

[identity profile] perlmonger.livejournal.com 2008-01-12 12:39 pm (UTC)(link)
That's a third option that I nearly included in the poll; it's more sensible IMO than Java et al going for option two.

I wanted to contrast the first two though, after addressing my irritation with Javascript by redefining String.split() in my main JS library. Context, FWIW, was dealing with an XMLhttp response that serialises a return numeric id set into a comma-delimited list in single attribute: treating the (entirely valid) possibility of an empty set as a special case made me itch.

[identity profile] spride.livejournal.com 2008-01-12 01:31 pm (UTC)(link)
Right, but in that case it's hardly $LANGUAGE's fault that XMLhttp responds with an empty string in certain cases and a serialized array in others. Can't you fix the XMLHttp response to hand you a consistent return every time?
ext_17706: (Default)

[identity profile] perlmonger.livejournal.com 2008-01-12 01:45 pm (UTC)(link)
What's the serialised form of an empty array? :)

[identity profile] spride.livejournal.com 2008-01-12 02:46 pm (UTC)(link)
If the standard form is [nnn,nnn,nnn,nnn] then [,,,]