develooper Front page | perl.perl5.porters | Postings from January 2014

Re: Range idea

Thread Previous | Thread Next
From:
Abigail
Date:
January 23, 2014 14:02
Subject:
Re: Range idea
Message ID:
20140123140237.GA32034@almanda.fritz.box
On Thu, Jan 23, 2014 at 09:17:16PM +0800, Xiao Yafeng 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..*] ?


Not only doesn't that solve the issue that Zefram is raising, it's
actually the start of a valid expression. Since *] is a variable,

    @foo[3..*]]

is valid, and I don't think the ambiguity whether '*]' is a variable,
or part of the new syntax can be resolved with limited lookahead.



Abigail

Thread Previous | Thread Next


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