Front page | perl.perl5.porters |
Postings from June 2022
goto and @_
Thread Next
From:
Ovid
Date:
June 3, 2022 16:50
Subject:
goto and @_
Message ID:
CA+M4CHsfnyVC9uvJhS82OJcZfh8yziWBRakFS5uEk5E0qiedmQ@mail.gmail.com
Hi all,
There's been a bit of discussion about removing @_ from signatured subs. I
am quite happy about this. I'm trying to remove them, but I have a sub
which looks like this:
sub import ( $class, @args ) {
my $real_import = get_real_import();
# do stuff
@_ = $class;
goto $real_import;
}
(This is very terse. It's actually part of the documented interface of
MooseX::Importer which can give me an import sub reference)
But in perldoc goto, we see this:
The "goto &NAME" form is quite different from the other forms of
"goto". In fact, it isn't a goto in the normal sense at all, and
doesn't have the stigma associated with other gotos. Instead, it
exits the current subroutine (losing any changes set by "local")
and immediately calls in its place the named subroutine using
the current value of @_. This is used by "AUTOLOAD" subroutines
that wish to load another subroutine and then pretend that the
other subroutine had been called in the first place (except that
any
*modifications to @_ in the current subroutine are propagated to
the other subroutine.*) After the "goto", not even "caller"
will be able to tell that this routine was called first.
So goto requires @_.
Is there a plan for this?
Curtis "Ovid" Poe
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/
Thread Next