On Tue, Sep 23, 2008 at 9:38 AM, TSa <[EMAIL PROTECTED]> wrote:

> HaloO,
> Moritz Lenz wrote:
>
>> In Perl 5 a negative limit means "unlimited", which we don't have to do
>> because we have the Whatever star.
>>
>
> I like the notion of negative numbers as the other end of infinity.
> Where infinity here is the length of the split list which can be
> infinite if split is called on a file handle. So a negative number
> could be the number of splits to skip from the front of the list.
> And limits of the form '*-5' would deliver the five last splits.
>

As another data point, this is the first thing I thought of when I read the
email regarding negative limits.  But then I thought "we're trying to get
away from so much implicit magic". And I'm not sure the failure mode is loud
enough when the skip-from-the-front semantics /aren't/ what you want (e.g.,
when the limit parameter is variable-ish)


 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)
>

I think this is a nice degenerate case.
>

Me too.


  2) A limit of 0 fail()s
>

This is a bit too drastic.


Indeed.



  3) non-positive $limit arguments are rejected by the signature (Int
> where { $_ > 0 })
>

I think that documents and enforces the common case best. But I would
> include zero and use a name like UInt that has other uses as well. Are
> there pragmas that turn signature failures into undef return values?
>
>
> Regards, TSa.
> --
>
> "The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
> "Simplicity does not precede complexity, but follows it." -- A.J. Perlis
> 1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan
>


my two cents,

-Scott

-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to