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

Re: Range idea

Thread Previous | Thread Next
From:
Xiao Yafeng
Date:
January 23, 2014 13:17
Subject:
Re: Range idea
Message ID:
CABPUXgBp1OvD5VRfmu7Hxs6bAM6MC6kVYPsa-Z35uKu=YNaz9A@mail.gmail.com
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..*] ?

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