mkirank has asked for the wisdom of the Perl Monks concerning the following question:
I am looking at the MetaModel in Pugs and trying to understand
In MetaModel.pm at the beginning there is an import function wherein the following subs are put in the name space
What happens when the below code is executed ?
also how does 2 parameters gets passed to the class method (name and params) ?
how do those subs with "DUMMY" get created
This gives the following in class ($name and $params)
In MetaModel.pm at the beginning there is an import function wherein the following subs are put in the name space
when the Object module is loaded the sub class in the Metamodel is called.my $caller_pkg = caller(); # meta model helpers *{$caller_pkg . '::class'} = \&class; *{$caller_pkg . '::role'} = \&role; # instance attribute access helpers *{$caller_pkg . '::_'} = \&_; # class attribute access helpers *{$caller_pkg . '::__'} = \&__;
What happens when the below code is executed ?
also how does 2 parameters gets passed to the class method (name and params) ?
how do those subs with "DUMMY" get created
class 'Perl6::Object' => { 'class' => { methods => { # the default .new() 'new' => sub { my ($class, %params) = @_; return $class->bless(undef, %params); }, .... .... ## rest of the code
This gives the following in class ($name and $params)
name is Perl6::Object params is $VAR1 = { 'class' => { 'methods' => { 'CREATE' => sub { "DUMMY" }, 'bless' => sub { "DUMMY" }, 'isa' => sub { "DUMMY" }, 'new' => sub { "DUMMY" }, 'can' => sub { "DUMMY" } } }, 'instance' => { 'methods' => { 'isa' => $VAR1->{'class'}{'me +thods'}{'isa'}, 'DESTROYALL' => sub { "DUMMY" + }, 'BUILDALL' => sub { "DUMMY" } +, 'can' => $VAR1->{'class'}{'me +thods'}{'can'} }, 'submethods' => { 'BUILD' => sub { "DUMMY" } } } };
Back to
Seekers of Perl Wisdom