At 12:37 AM 2000-10-06 -0400, you wrote:
>>>>>> "PRL" == Perl6 RFC Librarian <[EMAIL PROTECTED]> writes:
>
>PRL> =item 2. Empty trailing fields are currently suppressed (although a
>PRL> -1 as the third argument disables this).  I suggest that empty trailing
>PRL> fields be retained by default.
>
>Extremely useful, I rely on this. It makes non-existant fields and empty
>fields the same.

The current behavior makes trailing empty fields non-existent, and that's a
bizarre and nonintuitive thing to have be a default; if your code relies on
them being removed, then remove them explicitly, without expecting split to
do it for you /by default/ at the expense of all the people who would
expect a saner and less surprising default.
If you want trailing/leading/all nulls removed without having to type the
single line of code it'd take to do it explicitly, then have that be an
option to split; don't have it be a default.

I like clarity and I like concision and I like learnability, but not when
any causes the others to suffer unduly.

>PRL> =item 3. When not in list context, split currently splits into @_.  I
>PRL> suggest that this side-effect be removed.
>
>Makes it harder on one liners.
>
>       split; shift;

...assuming that your one-liner happens to want to do exactly what the
defaults are, and disregarding the cruft that this imposes on the rest of
the users and learners of the language, to say nothing of anyone who has to
make sense of your one-liner.

Besides:
  @_ = m/(\S+)/g; ...
is a still-concise alternative.  (And I think the parens are even optional.)

>PRL> =item 5. split ' ' (but not split / /) currently splits on whitespace,
>PRL> but also removes leading empty fields.  I suggest that this
>PRL> irregularity be removed.
>
>This is another useful default, what would you replace it with?

If people want
  grep $_ ne '', split /\s+/, THING
or
  THING =~ m/(\S+)/g
they /know/ where and how to get it.  (This is as opposed to all the people
who do not know that split(X, Y, -1) is the way to get it to stop deleting
trailing empties, and cannot be reasonably expected to guess something so
obscure.)

>This would also cause grief with qw()
>       @bar = qw(  this is the sentence );
>       $bar[0] eq "";
>       $bar[1] eq "this";
>Currently $bar[0] eq "this";

Ah yes, I forgot that qw still uses split.

Ahwell, just turn qw{THING} into:
  grep $_ ne '', q{THING} =~ m/(\S+)/g;
or an equivalent.

--
Sean M. Burke  [EMAIL PROTECTED]  http://www.spinn.net/~sburke/

Reply via email to