develooper Front page | perl.perl6.language | Postings from September 2008

Split with negative limits, and other weirdnesses

Thread Previous | Thread Next
Moritz Lenz
September 23, 2008 02:27
Split with negative limits, and other weirdnesses
Message ID:
Today a patch to rakudo brought up the question what split() should do
if the $limit argument is either zero or negative.

In Perl 5 a negative limit means "unlimited", which we don't have to do
because we have the Whatever star. A limit of 0 is basically ignored.

Here are a few solution I could think of
 1) A limit of 0 returns the empty list (you want zero items, you get them)
 2) A limit of 0 fail()s
 3) non-positive $limit arguments are rejected by the signature (Int
where { $_ > 0 })

Any thoughts?

Moritz Lenz |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About