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:
Nicholas Clark
Date:
May 8, 2012 03:25
Subject:
Re: [perl #47027] Documentation: BEGIN, END docs in wrong section
Message ID:
20120508102530.GF9069@plum.flirble.org
On Sat, May 05, 2012 at 09:15:29AM +0100, Denis Howe wrote:
> On Fri 2012-05-04 07:13:17, denis.howe@gmail.com wrote:

> > 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.)

Not quite true. The default array for shift is on @_, not @ARGV, inside them.
Yes, @_ is empty. But if you use shift; expecting it to be on @ARGV, you will
be confused. This is a trap I've fallen into.
 
> > There is an argument to be made that they belong in perlsub
> 
> Only if you can convince us they are subroutines.

You're not phrasing that correctly. They *are* subroutines. That's what they
are internally.

What matters is whether from a language user perspective whether they are so
far from subroutines that they have more in common with some other part of
the language than with subroutines.

Nicholas Clark

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