Questions tagged [meta-object-protocol]

6 questions
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
7
votes
1 answer

Using EXPORTHOW to make declarator that acts like "sub"

The excellent 2011 Advent of Raku post Meta-programming: what, why and how provides a few clear examples of using EXPORTHOW to create a declarator that acts like class. Here's the first: my class SingleInheritanceClassHOW is…
codesections
  • 8,900
  • 16
  • 50
6
votes
3 answers

What's the meta-object rule for naming grammar rules

As indicated in this issue, some token names clash with method names in the class hierarchy of Grammar (which includes Match, Capture, Cool, Any and obviously My.). For instance, `Mu.item grammar g { token TOP { }; token item {…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
3
votes
1 answer

Changing a class variable from outside the class

Finally, when I managed to understand how to fix this, that is, how to change the value of an internal dynamic variable, the code has moved on and now it is declared in this way: my int $is-win = Rakudo::Internals.IS-WIN; This is a class variable…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
1
vote
1 answer

Calling Class allocated slot on class-names in Common Lisp

Is there any way to call a :class allocated slot on the name of a class instead of an instance? Something like: (class-alloc-slot 'name-of-the-class)
Student
  • 708
  • 4
  • 11
0
votes
0 answers

Function to convert function to list in CLOS. Is it possible?

Is that possible to convert code to a list in CLOS? That is; is it possible to build a function that takes an argument f, which should be a function or method, and converts it to a List? The goal would be to visit the list elements in the same way…