Front page | perl.perl5.porters |
Postings from December 2019
Re: @_ Suppression
From: Dave Mitchell
December 3, 2019 14:08
Re: @_ Suppression
Message ID: 20191203140818.GW3620@iabyn.com
On Mon, Dec 02, 2019 at 01:56:40PM +0000, Zefram via perl5-porters wrote:
> Dave Mitchell wrote:
> > @_ will not be set, unset or localised on entry to or exit from
> > a signatured sub;
> Bad idea. Having a warning for recognisable use of @_ is better than
> nothing, but according to decisions we already made it's not enough.
> Way back, we determined that detection of the use of @_ wouldn't
> be sufficiently complete to serve as the trigger for @_ suppression.
> The reasons for that decision haven't changed. It is right that we paid
> attention to that issue in repeated decisions that we would not tie @_
> suppression to signatures. Nothing in the rationale for those decisions
> has changed either.
As I recall, you were very keen on it being orthogonal, and I hated the
idea. Since then, I have added two further proposals:
* query parameters, doing away with the need for @_
* a warning on most/all spottable uses of @_ in lexical scope.
So the only residual reason for keeping them orthogonal, as I understand
it, is when refactoring existing code to use signatures, where a function
makes use of @_ in such a way that it isn't spotted by visual code
inspection, isn't spotted by by the lexical warning, and doesn't trip
anything in the code's test suite.
And in a case like that, you'd still have the problem if the refactorer
failed to set the attribute / pragmata correctly to preserve @_, and if
they got that wrong, they wouldn't spot it due to all the above reasons.`
This really doesn't seem to me a good reason to maintain a whole duplicate
infrastructure, with adding a bunch of extra syntax, and having all the
signature code written so that it can pull the next arg from @_ or from
the stack, etc. Plus all the ambiguity, loss of optimisation potential,
and bugs if code blocks etc can manipulate @_ while its being processed.
The Enterprise is captured by a vastly superior alien intelligence which
does not put them on trial.
-- Things That Never Happen in "Star Trek" #10