ingydotnet/mo-pm

Default defaults too often

Closed this issue · 0 comments

Given the following code:

use 5.014;
package Foo {
    use Mo;

    has 'foo', is => 'rw', default => sub { say 'defaulting!'; 5 }
}

my $a = Foo->new;
say $a->foo;
$a->foo(undef);
say $a->foo;

The output is:

defaulting!
5
defaulting!
5

If we change Mo to Moose, defaulting happens only once. Not sure if bug, or just confusing.