Issue #21695 has been updated by Hanmac (Hans Mackowiak). @fredlinhares A really long time ago, while i was working with ruby and wxWidgets (C++ lib), i worked on this: https://github.com/Hanmac/rwx/blob/master/ext/main.hpp#L538 Where I was writing C macros to help me with writing getter and setter methods for all these different C++ classes. For example in my wxRect class ```C #define _self unwrap<wxRect*>(self) macro_attr(X,int) ``` macro_attr together with other macros, turned this into that: ```C DLL_LOCAL VALUE _getX(VALUE self) { return RB_INT2NUM(_self->GetX()); } DLL_LOCAL VALUE _setX(VALUE self,VALUE other) { rb_check_frozen(self); _self->SetX(RB_NUM2INT(other)); return other; } ``` nicely defined C functions that can be used for defining the attributes like this: ```C rb_define_attr_method(rb_cWXRect,"x",_getX,_setX); ``` which is just a fancy define method, but hidden so that rdoc doesn't read it: (i wanted to treat them as attributes, not methods) ```C rb_define_method(rb_cWXRect, "x", RUBY_METHOD_FUNC(_getX), 0); rb_define_method(rb_cWXRect, "x=", RUBY_METHOD_FUNC(_setX), 1); ``` ---------------------------------------- Feature #21695: Optimizing Ruby performance with Ruby itself instead of Rust https://bugs.ruby-lang.org/issues/21695#change-116963 * Author: fredlinhares (Frederico Linhares) * Status: Open ---------------------------------------- I am using ERB on top of C for a game I am making now. We can use the tool to improve the productivity, memory safety, and runtime speed for Ruby. It can also replace a Rust JIT compiler for better results. The only problem is that it requires some level of manual memory management, while Rust does it all for you. If I demonstrate that it is better than Rust in practice, would you be willing to incorporate it into the Ruby language? I want to know because making it more generic will require more effort from me; if you are not interested, I won’t make the tool public. -- https://bugs.ruby-lang.org/