perlmonger: (pete)
[personal profile] perlmonger
[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 ]

Some other response....

Date: 2008-01-11 05:32 pm (UTC)
From: [identity profile] marko-carter.livejournal.com
An error. Heh.

(no subject)

Date: 2008-01-11 05:36 pm (UTC)
From: [identity profile] purple-peril.livejournal.com
Two empty stringettes?

(no subject)

Date: 2008-01-11 07:23 pm (UTC)
From: [identity profile] blue-condition.livejournal.com
Depends how fascist you're feeling. Quick'n'dirty script languages - an arrey of empty strings; neo-nazi - an exception.

I'm a Unix pragmatist though - SIGSEGV will do nicely ;)

(no subject)

Date: 2008-01-11 07:48 pm (UTC)
From: [identity profile] ccomley.livejournal.com
Surely, it's two empty strings and an up quark?

(no subject)

Date: 2008-01-12 12:25 am (UTC)
From: [identity profile] quercus.livejournal.com
The usual answer is an array of a single empty string, but I've never liked this and prefer the empty array.

Python naturally does both, as this is the most confusing behaviour possible. It only makes sense in Sanskrit, under particular phases of the moon. If you specify the toke, it returns an array of one empty string. If you _don't_ specify the token, then it does "default-based splitting" and looks for a normalised sequence of a set of the usual whitespace characters. BUT it also changes its empty string behavour so that it then returns an empty array instead!

(no subject)

Date: 2008-01-12 01:27 am (UTC)
From: [identity profile] spride.livejournal.com
This is why people hate Python.

(no subject)

Date: 2008-01-12 12:29 pm (UTC)
ext_17706: (Default)
From: [identity profile] perlmonger.livejournal.com
Perl does the Right Thing IMO, which is to answer an edge case with the equivalent, and usually appropriate, edge case.

I can't get along with Python; too elegant for its own good, and significant leading whitespace makes me think of makefiles and sendmail. And COBOL.

(no subject)

Date: 2008-01-12 05:21 pm (UTC)
From: [identity profile] quercus.livejournal.com
Python is wonderfully elegant, which unfortunately is elegance in implementing the language, not using the bastard.

Strings return True if you test them with issequence() (i.e. "Is this some soprt of array I'm looking at). Yes, they are a sequence, in terms of "Do they support the iterator functions", but this also means it's hard to tell whether the parameter you've just been passed in single or multi-valued (Duck-typing Parseltongues do this sort of thing a lot). Did I receive one string or an array of many? Can't tell.

(no subject)

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

(no subject)

Date: 2008-01-12 12:39 pm (UTC)
ext_17706: (Default)
From: [identity profile] perlmonger.livejournal.com
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.

(no subject)

Date: 2008-01-12 01:31 pm (UTC)
From: [identity profile] spride.livejournal.com
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?

(no subject)

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

(no subject)

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

Profile

perlmonger: (Default)
perlmonger

July 2013

S M T W T F S
 123456
78910111213
14 151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Powered by Dreamwidth Studios