On 20. mars 2017 15:54, Patrick R. Michaud wrote:
On Mon, Mar 20, 2017 at 02:36:49PM +0100, Francesco Rivetti wrote:
On 18. mars 2017 11:54, Elizabeth Mattijsen wrote:

if (my $x = frobnicate(42)) {
    say $x
if frobnicate(42) -> $x {
    say $x

which is way more elegant. Should this make it wise to have a compile time
warning for the former then?

FWIW, the two snippets above are not exactly equivalent.  The scope of $x in 
the second version is limited to the block, while in the first version it 
extends beyond the if statement.

oh, in perl5 it is scoped inside the statement (but not garbage collected immediately after iirc)

    if (my $x = ...) { ... }

In this case, the "my" makes it pretty clear that the assignment is intentional 
and not a typo.

that would be lovely indeed


Reply via email to