Questions tagged [mop]

A meta-object protocol (MOP) is an interpreter of the semantics of a program that is open and extensible.

MOP stand for meta-object protocol.

A MOP determines what a program means and what its behavior is. It is extensible in that a programmer (or meta-programmer) can alter program behavior by extending parts of the MOP.

The MOP exposes some or all internal structure of the interpreter to the programmer.

The MOP may manifest as a set of classes and methods that allow a program to inspect the state of the supporting system and alter its behavior.

MOP's are implemented as object-oriented programs where all objects are meta-objects.

48 questions
11
votes
2 answers

Test if a class is a subclass of another class in common lisp

How do I see if one CLOS class is a subclass of another CLOS class?
krzysz00
  • 2,083
  • 12
  • 24
10
votes
4 answers

How can I extend Moose's automatic pragma exports?

You know how Moose automatically turns on strict and warnings during import? I want to extend that behavior by turning on autodie and use feature ':5.10' in my Moose classes. I've tracked down where Moose does this, in Moose::Exporter, which…
friedo
  • 65,762
  • 16
  • 114
  • 184
9
votes
1 answer

Writing an attribute trait

I'm about to choose what language to use for a new project: Perl5 or Perl6. 6 wins so far except that it is missing Moo's lazy attributes. The two implementations I found in modules are missing the key functionality. Hence, my attempt write my own…
Vadim Belman
  • 1,210
  • 6
  • 15
9
votes
2 answers

How to create a class that doesn't inherit from any other class?

If you create a class: class Foo { } the class will inherit all of its methods from Any, and then Mu. I want to create a class that doesn't inherit from any other class: it should contain a single FALLBACK method that should catch all method calls…
Elizabeth Mattijsen
  • 25,654
  • 3
  • 75
  • 105
8
votes
1 answer

How can I obtain a pointer to a Grammar token or regex?

This is similar to this question for classes, except the same procedure does not seem to work for Grammars. grammar TestGrammar { token num { \d+ } } my $test-grammar = TestGrammar.new(); my $token = $test-grammar.^lookup('num'); say "3" ~~…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
8
votes
1 answer

How do you show the type hierarchy of a value?

In Perl5 and Moose, linear isa or linearized isa helps make sense of class hierarchies. The method WHAT shows the concrete type of a value: > 42.WHAT (Int) How do I show something like > 42.hypothetical-type-hierarchy (Int) ┬ is (Cool) ─ is (Any) ─…
daxim
  • 39,270
  • 4
  • 65
  • 132
6
votes
1 answer

Defining classes with several API versions together

That's not apparently possible... role Versioned { method version () { return self.^api; } } class WithApi:ver<0.0.1>:auth:api<0> does Versioned {} class WithApi:ver<0.0.1>:auth:api<1> does Versioned {} say…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
2 answers

lisp: How to create temporary method specialization within a scope

In Common lisp: Redefine an existing function within a scope? the OP asked for something similar. But I want to create a method specializer, not a function. Essentially suppose that a method is defined such: defmethod my-meth ((objA classA) (objB…
Paralife
  • 6,116
  • 8
  • 38
  • 64
6
votes
1 answer

Where is "require" defined?

I have been looking in Rakudo source for the implementation of require, first out of curiosity and second because I wanted to know if it was returning something. I looked up sub require and it returned this hit, which actually seems to be the source…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
1 answer

Find out whether a container is a class or an object

I was curious about grammars being classes or singletons, so I created this small program to find out: grammar Mini { token TOP { \* \* } token word { \w+ } } proto sub is-class( | ) { * }; multi sub is-class( Grammar:D $g ) { return…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
6
votes
2 answers

Does Ruby have a Metaobject protocol and if not, is it possible to implement one?

Pardon my ignorance, but What is a Metaobject protocol, and does Ruby have one? If not, is it possible to implement one for Ruby? What features might a Metaobject protocol possess if Ruby was to have one?
horseyguy
  • 29,455
  • 20
  • 103
  • 145
6
votes
1 answer

Specialising on Vectors and Matrices

I am using common-lisp for my real-time graphics experiments and so far it has being great. My requirements for speed and easy compatibility with cffi mean I am using 'typed' arrays. The one area of the code which really feels ugly is the generic…
Baggers
  • 3,183
  • 20
  • 31
6
votes
1 answer

Turning off inline constructors with MooseX::Declare

Greetings, As a followup to my previous question about Moose, I've now run into a new problem. I've got a Moose class which uses Recipe 12 in order to extend a non-Moose parent class. Here it is: package MyApp::CGI; ### TODO: make this work with…
friedo
  • 65,762
  • 16
  • 114
  • 184
6
votes
1 answer

Dealing with multiple-inherited constructors in Moose

Greetings, I'm learning Moose and I'm trying to write a CGI::Application subclass with Moose, which is made difficult by the fact that CGI-App is not based on Moose. In my other CGI-App subclasses, I like to have a parent class with a setup method…
friedo
  • 65,762
  • 16
  • 114
  • 184
5
votes
1 answer

Custom slot options don't apply any reduction to its argument

Say if I define a metaclass that enhances standard slots with a validator slot, when I pass :validator (clavier:valid-email "The email is invalid") as an option, instead of storing the result of of the expression, which is a funcallable, it stores…
PuercoPop
  • 6,707
  • 4
  • 30
  • 40
1
2 3 4