-
Notifications
You must be signed in to change notification settings - Fork 597
Description
As part of my research on Fatalization of currently deprecated goto
construct I have been
re-reading our current documentation of goto
in blead and have been trying
to locate in our test suite examples of each claim made in that documentation.
What we find -- or fail to find -- there will have an impact on the
documentation updates provided as part of a pull request like the current
#23782. I've posted the preliminary results
of that documentation review
here.
This is the ninth in a series of GH issues addressing the items which I
believe are lacking in that documentation.
perldoc -f goto
states:
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.
NAME needn't be the name of a subroutine; it can be a scalar
variable containing a code reference or a block that evaluates
to a code reference.
Do we have any examples of goto BLOCK-THAT-EVALUATES-TO-CODE-REFERENCE?
Probably not; ack '\bgoto\s*\{' t/op/goto*
turned up nothing.
Write some unit tests that exercise this. Place them in `t/op/goto-sub.t'.