Front page | perl.perl5.porters |
Postings from January 2014
Re: Range idea
Thread Previous
|
Thread Next
From:
H.Merijn Brand
Date:
January 23, 2014 13:45
Subject:
Re: Range idea
Message ID:
20140123144455.58a84e7f@pc09.procura.nl
On Thu, 23 Jan 2014 21:17:16 +0800, Xiao Yafeng <xyf.xiao@gmail.com>
wrote:
> On Thu, Jan 23, 2014 at 9:03 PM, Zefram <zefram@fysh.org> wrote:
> > H.Merijn Brand wrote:
> >>Why cannot we use open range operators in this case?
> >
> > They wouldn't really be range operators. @foo[3..5] is the composition
> > of a range operator with the @foo[LIST] operator. Crucial to this
> > is that the range expression 3..5 is meaningful on its own: in list
> > context it generates the list (3,4,5). But your open range couldn't
> > work that way. In @foo[3..], the 3.. doesn't mean anything specific on
> > its own. That doesn't mean we can't do it at all, but it does mean that
> > @foo[SCALAR..] is a specific operator unto itself, and the open range
> > can't be used anywhere else even though it looks like it could be used
> > in a different context. It's not a nice design.
>
> how about @foo[3..*] ?
I thought of that too after implementing RFC7111 on Text::CSV_XS, which
defines this as file.csv#col=2;4-6;9-*
In perl however that * would make no sense
I understand that in the given example SCALAR .. is a range operator
I also understand that my example is wrong. It is harder to come up
with good examples of code that is impossible now :)
I can imagine that "unended rages inside a valid subscript" can be
dealt with differently in the parser. I do not see backward
compatibility issues, but I might be shortsighted
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.19 porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Thread Previous
|
Thread Next