Skip to content

Proposal for publc/private/protected #5

@cub-uanic

Description

@cub-uanic

I would lik e to have possibility to declare private and protected parts of class, like this:

       class SomeClass {
           # by default, everything is public
           has 'var1' => ( isa => 'Num', is => 'rw', default => 0 );
           method sub1 (Num $arg) { .... }

           private {
               has 'var2' => ( isa => 'Num', is => 'rw', default => 0 );
               method sub2 (Num $arg) { .... }
           }

           protected {
               has 'var3' => ( isa => 'Num', is => 'rw', default => 0 );
               method sub3 (Num $arg) { .... }
           }
       }

Or like this:

       class SomeClass {
           # by default, everything is public
           has 'var1' => ( isa => 'Num', is => 'rw', default => 0 );
           method sub1 (Num $arg) { .... }

           private has 'var2' => ( isa => 'Num', is => 'rw', default => 0 );
           private method sub2 (Num $arg) { .... }

           protected has 'var3' => ( isa => 'Num', is => 'rw', default => 0 );
           protected method sub3 (Num $arg) { .... }
       }

Or even combination of both possibilities :)
Would you like to make such extension?
I can try to help, but I'm far away yet from MooseX::Declare internal magic :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions