fancy icon indicating copy to clipboard operation
fancy copied to clipboard

Compile class & method defs to message sends

Open bakkdoor opened this issue 14 years ago • 1 comments

Change ClassDef and MethodDef nodes to compile to message sends using Class#subclass: and Class#define_method:with_args: or similar. Need to make sure that when reopening a class, it isn't redefined but instead code gets just attached to it. This will allow one to dynamically hook into the class and method definition process, being able to ovverride those methods or add custom logic in cases where it's needed.

bakkdoor avatar Oct 01 '11 19:10 bakkdoor

Fooled around with this idea some (a lot) tonight. To really make any major changes to underlying class semantics on Rubinius will probably require a ton of work and messing about in the internals. (https://github.com/dirk/fancy/compare/master...class_foolings)

However, there are some places that small changes can be made to slightly tweak what internal methods are being called. (eg: https://github.com/rubinius/rubinius-ast/blob/2.0/lib/rubinius/ast/definitions.rb#L758 and https://github.com/rubinius/rubinius/blob/master/kernel/delta/rubinius.rb#L17 for class definitions) So it looks like it's possible to at least override (through the Fancy AST subclasses or monkey-wrenching into Rubinius (yay dynamic languages)) some of these internals without too much work/danger of breakage.

dirk avatar Oct 20 '13 05:10 dirk