develooper Front page | perl.perl5.porters | Postings from January 2022

Re: Benchmarking a 'no-snails' world (was: Re: PSC #049 2022-01-07)

Thread Previous | Thread Next
Darren Duncan
January 19, 2022 03:49
Re: Benchmarking a 'no-snails' world (was: Re: PSC #049 2022-01-07)
Message ID:
On 2022-01-17 3:17 p.m., Tom Molesworth via perl5-porters wrote:
> That sounds like a big change in behaviour? It seems like this would lead to the 
> following situation:
> - everything in the signature is now an alias instead of a copy
> - signature args are no longer refcounted (stack-not-refcounted has long been a 
> source of various problems!)
> The first one would lead to very surprising behaviour with cases like `sub ltrim 
> ($x) { $x =~ s{^\s+}{}; $x }`, and the second likewise for lexical captures such 
> as `(sub ($x) { sub { $x } })->($thing_that_drops_out_of_scope_shortly_after)`.

Surprising behavior can be avoided by forbidding assignment to routine 
parameters.  I believe it is a best practice to forbid such assignments anyway 
even where it is supported by the language.  Assigning to parameters just makes 
code harder to understand what is going on, one can't reliably look at the 
parameter from anywhere in the code and know it has the argument that was passed 
in, maybe it does, but maybe it doesn't. -- Darren Duncan

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