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

Re: Range idea

Thread Previous | Thread Next
From:
Abigail
Date:
January 23, 2014 17:27
Subject:
Re: Range idea
Message ID:
20140123172727.GB32034@almanda.fritz.box
On Thu, Jan 23, 2014 at 04:47:41PM +0000, Paul LeoNerd Evans wrote:
> On Thu, 23 Jan 2014 17:32:53 +0100
> Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:
> 
> > Why not simply add a weak keyword and avoid the entire syntax design
> > exercise?
> > 
> >    qw( a b c d )[2 .. lastindex]
> 
> That doesn't solve the problem any more than any of the others do.
> 
> What would this do?
> 
>   my @range = 2 .. lastindex;
>   my @letters = ('A' .. 'Z');
> 
>   say @letters[@range];


die? warn, and continuing with @range empty? I don't really see the
problem of 'lastindex' only making sense in specific environments.
'next', 'last', 'redo' don't make sense outside of a loop, and Perl
just dies when encountering them outside of a loop. If such a 'lastindex'
(or whatever syntax is used) would die when used outside of an indexing
operation, what is the loss?

> ?
> 
> Ultimately, 'lastindex' is going to fail however this works.

So what? Should "it's going to fail if you try to use it in a
context where it won't make sense" stop anyone from implementing
something that is useful in a context where it makes sense?



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