mercredi 8 avril 2020

If MyMeta is the MyClass metaclass in Python 3.x, what types of manipulation can MyMeta do with MyClass?

The goal is to compare the power of Python metaclasses with metaprogramming systems of other languages such as Groovy, Xtend, Nemerle, CLOS, OpenJava, BSJ (BackStage Java), Iguana/J, compiler plugins for Scala, Cyan, etc.

Assume class MyMeta is the metaclass of class MyClass.

Can MyMeta generate code in MyClass that intercepts get and set of MyClass instance attributes?

Can a method of MyMeta be called when MyClass is inherited, even if the subclass metaclass is not MyMeta?

Can a method of MyMeta be called when a MyClass method is overridden in a subclass, even if the subclass metaclass is not MyMeta?

Can a method of MyMeta be called when a method of MyClass uses an attribute that has not been declared?

Can MyMeta handle the AST of MyClass or another equivalent representation? For example, can MyMeta check if each class method has at most 20 statements? Or add a statement after the second method statement? Or rename a method?





Aucun commentaire:

Enregistrer un commentaire