The MOP is an API to the object-oriented system. With it, you can query classes and their attributes and methods about their properties. It can also be used to create whole new classes (or other types) programatically.
Languages that have a MOP have a great advantage because, even though the object system is in a sense always arbitrary, at least now it's programmable. // Carl On Mon, Oct 28, 2013 at 2:17 PM, Richard Hainsworth <rich...@rusrating.ru> wrote: > Moritz, > > You are the everflowing font of knowledge. Thanks. > > However, I read the synopsis on objects and did not find the .get_value > method. > > Pardon the ignorance, but what is "the MOP". I sometimes get floored by the > jargon. > > I read about the indirection for methods, but how does that relate to > attributes? > > Richard > > > On 10/28/2013 01:45 PM, Moritz Lenz wrote: >> >> Hi Richard, >> >> On 10/28/2013 08:07 AM, Richard Hainsworth wrote: >>> >>> Perhaps I am using class incorrectly, but I set up a class, then change >>> some of the parameters in an instance of the class. Next I would like to >>> discover what the current state of the instance is. >> >> >> There is a way to introspect through the MOP: >> >> class A { has $!x = 42; }; >> my $obj = A.new; >> say A.^attributes[0].get_value($obj); >> >> It's not straight forwards, and that's actually a feature :-) >> >> The usual way to go is through the accessors, and indirect method calls >> with $obj."$name"(); >> >> Cheers, >> Moritz > >