develooper Front page | perl.perl5.porters | Postings from April 2012

Re: [perl #108286] Wishlist: Overridable keywords

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
April 24, 2012 11:52
Subject:
Re: [perl #108286] Wishlist: Overridable keywords
Message ID:
20120424185158.GI4502@tozt.net
On Tue, Apr 24, 2012 at 08:24:40PM +0200, Johan Vromans wrote:
> "Father Chrysostomos via RT" <perlbug-followup@perl.org> writes:
> 
> > How about ‘given’?  I would love to be able to override it with
> > something that actually works, in which case I would need ‘when’ as well.
> >
> > How about being able to override ‘if’ to make if(<>) dwim?  How about
> > overriding ‘while’ to make a non-dwimmy do-what-I-say version?  These,
> > of course, don’t have to be global overrides.
> 
> My first reaction to this thread was: override okay, but then as a set
> of keywords. if, else and elsif go together. given, when etc likewise.
> 
> I can easily imagine a pragma that changes the behaviour of such a set
> of keywords.
> 
> But just overriding keywords like if independently... Yuck.
> 
> BTW, for the if(<>) dwim, I'd consider overriding the readline function
> instead.

given/when are actually independent keywords - they are actually more
like for/next/last/etc. (whether this is actually a good idea is
debatable, but that is how they work currently). Overriding elsif
outside of the context of if() doesn't actually make any sense - elsif
isn't (or shouldn't be, anyway) a keyword on its own, it is just a token
that is an expected part of parsing an if statement.

-doy

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