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

[perl #108286] Wishlist: Overridable keywords

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
May 20, 2012 11:16
Subject:
[perl #108286] Wishlist: Overridable keywords
Message ID:
rt-3.6.HEAD-9785-1337537792-1000.108286-15-0@perl.org
On Sun May 20 04:41:46 2012, zefram@fysh.org wrote:
> Eric Brine wrote:
> >PS - Something to test: What happens if one overrides C<elsif> using the
> >keyword plugin? Does it break C<if>?
> 
> I think the best way to do this (in the long run) is that the code to
> parse the "if" syntax (which is magically attached to &if), when it sees
> an identifier in a place that might be an "else" or "elsif", uses the
> normal sub name lookup mechanism to decide what it means.  Having resolved
> the identifier to a sub ref, it checks whether this matches the &else or
> &elsif that it knows about, and acts accordingly.  &elsif is, of course,
> a dummy sub, with parser magic that will just signal an error, because
> "elsif" isn't allowed to be used on its own.  The result is that you can
> change the spelling of "elsif" by doing things like "*orif = \&elsif".
> A user-added "if"-alike can use exactly the same mechanism, using either
> the standard &elsif or its own dummy subs.

That’s a nice solution that solves all the problems I brought up..

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=108286

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