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

Re: [perl #47027] Documentation: BEGIN, END docs in wrong section

Thread Previous | Thread Next
From:
Denis Howe
Date:
May 5, 2012 01:16
Subject:
Re: [perl #47027] Documentation: BEGIN, END docs in wrong section
Message ID:
CAL9ax1Sp2ZZX7+HHicbXArc+QGYOzeSbZa+-2ZNOyNj2n2vv8w@mail.gmail.com
On Fri 2012-05-04 07:13:17, denis.howe@gmail.com wrote:

> The section "BEGIN, CHECK, INIT and END" in the
> "perlmod" docs has nothing to do with modules and should
> be moved to the "perlsyn" "Compound Statements" section
> where any reasonable person would expect to find it.

tchrist1 via RT <perlbug-followup@perl.org> wrote:

> Things like UNITCHECK and END are used as per-module setup and cleanup code

I can't believe I'm arguing with Tom :-) but...

Many Perl features are relevant to good module design but that doesn't
mean they should all be documented in perlmod.  These special blocks
are not specific to modules, they can be used in "eval" strings for
example.

> these are *subroutines*.

So why does the doc say that it is not good style to prefix them with
"sub"?  Because they don't behave like subroutines in any way - you
can't call them, they don't take arguments or return anything.  (In
fact the option to prefix them with sub sounds like a confusing,
historic wart that should be retired.)

> They are not control statements like if, while, ....

That is quite clearly exactly what they are - special control
statements.  They are all about flow of control, just like if, while
and the rest.  The only difference is that these special blocks
control flow around the parsing and compilation phases as well as just
during execution.  If anything they are like the mythical "come from"
statements (http://foldoc.org/come+from).

> control stuctures go in perlsyn.

Exactly.

> There is an argument to be made that they belong in perlsub

Only if you can convince us they are subroutines.

> but you cannot say they are unrelated to modules.

Not unrelated, but not specific to modules.

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