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

Split with negative limits, and other weirdnesses

From:
Moritz Lenz
Date:
September 23, 2008 02:27
Subject:
Split with negative limits, and other weirdnesses
Message ID:
48D8B67C.8010600@casella.verplant.org
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



-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About