mop

Defining classes with several API versions together

孤者浪人 提交于 2020-05-29 02:37:09
问题 That's not apparently possible... role Versioned { method version () { return self.^api; } } class WithApi:ver<0.0.1>:auth<github:JJ>:api<0> does Versioned {} class WithApi:ver<0.0.1>:auth<github:JJ>:api<1> does Versioned {} say WithApi:api<0>.new.version; say WithApi:api<1>.new.version; This dies with ==SORRY!=== Error while compiling /home/jmerelo/progs/perl6/my-perl6-examples/api-versioned.p6 Redeclaration of symbol 'WithApi' at /home/jmerelo/progs/perl6/my-perl6-examples/api-versioned.p6

Is there a way to gather slot-definition-readers from all the inheritance tree?

廉价感情. 提交于 2020-01-11 10:23:27
问题 The generic function slot-definition-readers gets an argument that must be a direct-slot-definition . If an object is an instance of a class that inherits from another class how can I get hold of the readers of all the effective-slots of the object? Do I manually have to traverse the tree and call slot-definition-readers on the result of class-direct-slots in each superclass, gathering the results, or is there another way that I am not aware of? 回答1: This "community wiki" answer is here to

Is there a way to gather slot-definition-readers from all the inheritance tree?

只愿长相守 提交于 2020-01-11 10:23:11
问题 The generic function slot-definition-readers gets an argument that must be a direct-slot-definition . If an object is an instance of a class that inherits from another class how can I get hold of the readers of all the effective-slots of the object? Do I manually have to traverse the tree and call slot-definition-readers on the result of class-direct-slots in each superclass, gathering the results, or is there another way that I am not aware of? 回答1: This "community wiki" answer is here to

Dealing with multiple-inherited constructors in Moose

懵懂的女人 提交于 2019-12-13 13:02:35
问题 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 that looks at the child class's symbol table and automatically sets up the runmodes. I figure I can use Moose's metaclass facilities to achieve the same thing in a cleaner way. So here is what I have in my parent class: use MooseX::Declare; class

MOP: acess any slot definition ? (mito's col-type)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 01:38:06
问题 I define a class which uses the Mito ORM, the slots define a :col-type : (isbn :accessor isbn :initarg :isbn :col-type (or (:varchar 128) :null)) How to get the :col-type definition ? Since this is a slot in my class definition, is there no generic way to access it, like slot-definition :col-type ... ? On the clos-mop documentation, I only find how to access slot-definition-allocation slot-definition-initargs slot-definition-initform slot-definition-initfunction slot-definition-name slot

How can I extend Moose's automatic pragma exports?

半腔热情 提交于 2019-12-03 17:23:00
问题 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 assembles a custom import sub for Moose that calls strict->import and warnings->import for the calling class. However, I can't figure out a way to extend this import method in a Moose-ish way. How should I handle this? http://www.friedo.com/bullwinkle

Is there a way to gather slot-definition-readers from all the inheritance tree?

此生再无相见时 提交于 2019-12-02 02:52:17
The generic function slot-definition-readers gets an argument that must be a direct-slot-definition . If an object is an instance of a class that inherits from another class how can I get hold of the readers of all the effective-slots of the object? Do I manually have to traverse the tree and call slot-definition-readers on the result of class-direct-slots in each superclass, gathering the results, or is there another way that I am not aware of? coredump This "community wiki" answer is here to provide an implementation of this feature. What follows uses no destructive operation (NCONC, MAPCAN)