Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for "has" attributes #139

Open
mbuc82 opened this issue Sep 6, 2023 · 1 comment
Open

Support for "has" attributes #139

mbuc82 opened this issue Sep 6, 2023 · 1 comment

Comments

@mbuc82
Copy link

mbuc82 commented Sep 6, 2023

Hello,

it would be great, if PLS would support the "has" attribute definitions from the Moose/Moo/Mo implementations of Perl, to be usable in the outline part of VSCode.

Moose

has 'node' => (is => 'rw', isa => 'Any');
 
has 'children' => (
    is      => 'ro',
    isa     => 'ArrayRef',
    default => sub { [] }
);
 
has 'parent' => (
    is          => 'rw',
    isa         => 'Tree',
    weak_ref    => 1,
    handles     => {
        parent_node => 'node',
        siblings    => 'children',
    }
);

Moo

has taste => (
  is => 'ro',
);
 
has brand => (
  is  => 'ro',
  isa => sub {
    die "Only SWEET-TREATZ supported!" unless $_[0] eq 'SWEET-TREATZ'
  },
);
 
has pounds => (
  is  => 'rw',
  isa => sub { die "$_[0] is too much cat food!" unless $_[0] < 15 },
);

Mo

has name1 => ( default => sub { 'Joe' } );
has name2 => ( builder => 'name_builder' );
has name3 => ( coerce => sub {$_[0]} );
has name4 => ( is => 'ro' );
has name4 => ( required => 1 );

Apart from that, the step to Perl's Cor implementation would also be a bit smaller.

@FractalBoy
Copy link
Owner

Thanks for the suggestion. You're right, there should be some handling for commonly used OO systems in Perl.

I'll probably wait until it's a bit more mature before working on feature 'class'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants