If I take the ruby code
puts "Hello World!"
and rewrite it using the Ruby C API
#include "ruby.h" int main() { ruby_init(); rb_funcall(Qnil, rb_intern("puts"), 1, rb_str_new2("Hello World!")); ruby_finalize(); return 0; }
and compile it, is this a way to compile Ruby code?
If I create a program that uses Ripper
to parse Ruby code and rewrite it as C, can I call it a “Ruby compiler”? Is there some ruby code that cannot be rewritten in Ruby this way? Has anyone tried to write this "compiler" before?
Guilherme bernal
source share