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

[perl #43068] BEGIN, CHECK, INIT, END should take EXPR in addition to BLOCK

From:
David Nicol
Date:
May 29, 2007 17:49
Subject:
[perl #43068] BEGIN, CHECK, INIT, END should take EXPR in addition to BLOCK
Message ID:
rt-3.6.HEAD-1668-1180466844-1642.43068-75-0@perl.org
# New Ticket Created by  David Nicol 
# Please include the string:  [perl #43068]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43068 >




-----------------------------------------------------------------
[Please enter your report here]

Occasionally the fact that there is an implied block
around a C<use> statement creates an unwanted side effect
which is that lexical variable declarations on the use
line go away:

    use SpecialVariable my $honk => 'ooga';

must be written as 

    my $honk; use SpecialVariable $honk => 'ooga';

This is not a big deal.  However, in discussions of
whether to document this or not, it became apparent that
the situation is considered a bug to fix rather than a
behavior to document more clearly than the implication
that of course this would happen in perlfunc/use's statement
of exact equivalence:

       use Module LIST [...] is exactly equivalent to

             BEGIN { require Module; import Module LIST; }

       except that Module must be a bareword.

Anyway, my proposal is that the situation could be remedied
by loosening the syntax of BEGIN etc. to allow rounds
instead of curlies, which would not create a new lexical pad,
after which C<use> would be modified to have an accurate
documented equivalence of

             BEGIN ( require Module; import Module LIST )


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=wishlist
---
This perlbug was built using Perl v5.8.8 in the Red Hat build system.




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