develooper Front page | perl.perl5.porters | Postings from December 2021

Re: "no snails"; or having signatured subs complain about @_

Thread Previous | Thread Next
December 6, 2021 19:40
Re: "no snails"; or having signatured subs complain about @_
Message ID:
From the keyboard of Paul "LeoNerd" Evans [06.12.21,17:50]:

> On Mon, 6 Dec 2021 17:57:27 +0100 (CET)
> Tina Müller <> wrote:
>> On Mon, 29 Nov 2021, Paul "LeoNerd" Evans wrote:
>>> The final part of the "signatures" feature still to be implemented,
>>> is getting rid of the @_ setup as part of OP_ENTERSUB when entering
>>> a signature'd sub, for the speed benefit it gives. I've been
>>> thinking about how to implement this.
>> Sorry if this has been discussed before somewhere, but I'm wondering
>> how to assign values to @_ when using signatures. Is there a way, or
>> will there be?
>> e.g.
>>      sub inc($x) {
>>          $_[0]++  # how to do this?
>>      }
> Short answer; "don't do that".
> Longer answer: Maybe we'll consider some sort of `:alias` attribute for
> permitting that at some future time:
>  sub inc($x :alias) { $x++ }

So, a mere "sub inc($x) { ... }" doesn't pass in $x as an alias already?
It has to be declared as such? using signatures there is no in-place
argument modification except with such a clumsy declaration?

The "signatures" ship sailed long ago, and yes, signatures do have their
benefits, but - @_ and its implicity, as well as wantarray and such,
pertain to the very foundations of perl, in what is its linguistic part.

It is my impression that this part is being given up to streamline perl
and make it more akin and compatible to other languages.


_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                               /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About