develooper Front page | perl.perl5.porters | Postings from November 2003

[DOCPATCH] BEGIN, CHECK, INIT, END explained more

Thread Next
From:
Elizabeth Mattijsen
Date:
November 29, 2003 14:16
Subject:
[DOCPATCH] BEGIN, CHECK, INIT, END explained more
Message ID:
p05111b01bbeec2e8bf30@[192.168.56.3]
Having been bitten today by the fact that I can't call an INIT block 
by name (which is not documented as far as I know), I decided to take 
the bull by the horns and write some corrections and additional text 
in perlmod.pod and perlsub.pod.

The most important thing about this patch, is that it introduces (I 
think) the term "named CODE blocks)" instead of "special subroutines" 
or "special functions".  I also differentiated BEGIN, CHECK, INIT and 
END from the "other" all uppercase subroutines, as these are special.

I also added "PerlIO::via" as an extra reference to all uppercase subroutines.

The explanations reflect my current understanding of the matter.  I 
hope they are correct.

A special section may need to be added later, to show that only 
BEGIN, CHECK, INIT and END don't need the "sub" prefix, and the other 
all uppercase subroutines _do_ need it (even if they don't generate 
any errors during compilation).
.

$ perl -MO=Deparse -e 'BEGIN { foo => "bar" }'
sub BEGIN {
     'foo', 'bar';
}
-e syntax OK

$ perl -MO=Deparse -e 'CLONE { foo => "bar" }'
do {
     'foo', 'bar'
}->CLONE;
-e syntax OK



Liz
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