develooper Front page | perl.perl5.porters | Postings from June 2013

Removing do SUBROUTINE(LIST) (was: What does "deprecated" mean?)

Thread Next
June 27, 2013 22:48
Removing do SUBROUTINE(LIST) (was: What does "deprecated" mean?)
Message ID:
Peter Rabbitson <> writes:

> On Thu, Jun 27, 2013 at 10:56:13AM +0100, Nicholas Clark wrote:
>> The case of (IIRC) do subroutine syntax springs to mind. IIRC chromatic
>> calculated that 2% (or was it 4%) of the Perl grammar exists just to deal
>> with it.

It's 43 out of 1444 lines in perly.y, so just a hair under 3%.

> Being 2 (or 4%) of the grammar, and being a special case of invocation 
> (thus likely having an effect on entersub or somesuch)

It doesn't have any runtime effect, it compiles to a bog standard
ENTERSUB op (with the OPf_SPECIAL flag set, which is only used by
B::Deparse to output the "do" correctly).

> - in any case - there is *tangible* technical benefit of removing
> this. I do not believe it would be reasonable to complain if this were
> removed during a *related* encounter with this part of the
> parser/lexer/whathaveyou.

It's entirely self-contained in the grammar
( et seq), so
the only reason to touch it would be if you're changing how ENTERSUB ops
are built in general.

Out of curiosity, I went and ripped it (and related tests) out. The
diffstat, excluding generated files, is:

 perly.c              |  3 --
 perly.y              | 43 -----------------------------
 pod/perlfunc.pod     |  6 ----
 t/lib/warnings/perly | 30 --------------------
 t/op/do.t            | 66 ++------------------------------------------
 t/op/lexsub.t        | 31 +--------------------
 6 files changed, 3 insertions(+), 176 deletions(-)

And a run adds:

 perly.act |  304 ++++++-------
 perly.h   |    2 +- | 1229 +++++++++++++++++++++++++----------------------------
 3 files changed, 704 insertions(+), 831 deletions(-)

The results are at if
anyone is interesed.

"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About