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

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

David Nicol
May 29, 2007 17:49
[perl #43068] BEGIN, CHECK, INIT, END should take EXPR in addition to BLOCK
Message ID:
# New Ticket Created by  David Nicol 
# Please include the string:  [perl #43068]
# in the subject line of all future correspondence about this issue. 
# <URL: >

[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]
This perlbug was built using Perl v5.8.8 in the Red Hat build system. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About