xslate / p5-Mouse

Lightweight class builder for Perl, as a subset of Moose
https://metacpan.org/release/Mouse
Other
46 stars 32 forks source link

unicode attributes #105

Open tlby opened 4 years ago

tlby commented 4 years ago

It seems like Mouse is not adding methods for attributes with unicode names though I can't find any limitations that would prevent it.

use strict;
use warnings;
use utf8;

package C1 {
    use Mouse;
    has 'pi', is => 'ro', isa => 'Num', default => 2 * atan2(1, 0);
    no Mouse;
    sub π { goto \&pi }
}

package C2 {
    use Mouse;
    has 'π', is => 'ro', isa => 'Num', default => 2 * atan2(1, 0);
    no Mouse;
}

binmode STDERR, ':utf8';

eval {
    my $c1 = C1->new();
    print $c1->π, "\n";
};
warn $@ if $@;

eval {
    my $c2 = C2->new();
    print $c2->π, "\n";
};
warn $@ if $@;

is giving me the output:

3.14159265358979
Can't locate object method "π" via package "C2" at bug.pl line 29.

Is this something that should work?