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 DuncanThread Previous | Thread Next