Hi,

From: "Gavin Kistner" <gavin / refinery.com>
> On Jul 13, 2004, at 5:41 PM, Lloyd Zusman wrote:
> >
> > Just think of split(" ") as a special case which performs a very useful
> > function.
> 
> Ick.
> 
> Not at your summary, Lloyd, but at this situation. This is...stupid.
> I don't know what else to call it.
> 
> It's a non-sensical idiom, sure to bite more than a few people. It's 
> like Ruby implemented the behavior of a bug that Perl people have 
> gotten used to relying on.
> 
> What possible benefit is there to typing split(" ") vs. split(/\s/)? 
> One saved character (but two shift key presses!)?

They aren't the same.  I agree that having a special case
feels funky... But split(" ") embodies functionality that's
not as easy to duplicate as /\s/ .  For instance:

>> "   a    b    c   ".split(" ")
=> ["a", "b", "c"]

>> "   a    b    c   ".split(/\s/)
=> ["", "", "", "a", "", "", "", "b", "", "", "", "c"]

>> "   a    b    c   ".split(/\s+/)
=> ["", "a", "b", "c"]

Even with /\s+/ we're getting a leading empty field that
the " " special case eliminates for us.

I've never been sure how to write a regexp for split that
does what " " does.  I keep thinking it'd need a variable-
width negative lookbehind assertion... which I don't think
even Perl's regex engine supports... Something like:

  /(?<!^\s+)\s+/  ...uh....

...Maybe there's another way to do it... If anybody knows
I'd like to learn...

> It is counter-intuitive to people without prior Perl experience. Now 
> that Ruby is taking off in its own right, does Ruby need to continue 
> supporting gross global $ vars, this, and other ugly Perl-isms just to 
> try and make Ruby feel more like Perl?

Some are Perl-isms, some are Shell-isms.  They're fantastic
for one-liners... If Ruby was neutered to be lousy for one-
liners, I'd be thoroughly bummed . . .


Regards,

Bill