C
Colin Mackenzie iv
Sorry if this belongs in Ruby Core, though I don't really think it does
since it's more about writing gems than it is Ruby itself.
I've been looking (on and off) for the past several months for a way to
accomplish this topic's namesake. There are many gems for Ruby 1.8x and
a few that even support earlier previews of 1.9.1, but I haven't found
any that support the current version (1.9.2) or even the official 1.9.1
release.
For reference, a few of the better-known examples of what I'm looking
for are:
ParseTree - http://rubyforge.org/projects/parsetree/
RubyNode - http://rubynode.rubyforge.org/api.html
I understand that at some point, 'node.h' was removed from the public
API. This is one of the reasons that most of these gems don't support
the current release. So I guess my questions are...
1. Are there ANY gems out there that have found a way to inspect the
node hierarchy in 1.9 that I might have missed?
2. The ruby-debug19 gem seems to get around the missing header files by
relying on the ruby_core_source gem. I didn't look at it in much detail,
but that gem seems to pull in the missing headers directly. That said,
if one were to take this approach, would it be feasible at all to
implement the functionality I'm looking for? Or is something missing at
a much more fundamental level? I've tried to hack a proof of concept
together (several times) and they seem to _almost_ work, but invariably
seem to end with a segfault. Even the "rb_parser_dump_tree" function in
the Ruby19 node.c gives me a segfault, though it does make it plainly
obvious that it was never meant for public consumption.
3. Is there any resource, in addition to reading the Ruby source code
itself, that might document the various macros in node.h? I've been able
to figure some of them out but others have me downright stumped. I
suspect my lack of understanding these macros may be related to the
inevitable segfaulting of my code (though that still doesn't explain the
rb_parser_dump_tree segfaults).
4. Is this really a big deal? I have some really interesting ideas for
gems that I'd dearly like to implement, but I'm afraid to bother with
them because relying on RubyNode or ParseTree would make my work totally
incompatible with Ruby 1.9. Are people actually using 1.9 in the field
yet? For example, while Rails 3 does support 1.9.2 officially, is anyone
actually planning to use it with 1.9 or will the user base be sticking
with 1.8.7 for the foreseeable future (hopefully long enough for the
missing node stuff to be added back into 1.9)?
Sorry for the novel. I guess I'm just at a point where I don't know
whether to shrug off this issue and stick with 1.8; implement it myself;
wait for someone else (or a new version of Ruby); or drop my ideas
altogether (which would be truly disappointing, but is unavoidable if
node inspection is gone forever).
Thanks for the help,
Colin MacKenzie IV
since it's more about writing gems than it is Ruby itself.
I've been looking (on and off) for the past several months for a way to
accomplish this topic's namesake. There are many gems for Ruby 1.8x and
a few that even support earlier previews of 1.9.1, but I haven't found
any that support the current version (1.9.2) or even the official 1.9.1
release.
For reference, a few of the better-known examples of what I'm looking
for are:
ParseTree - http://rubyforge.org/projects/parsetree/
RubyNode - http://rubynode.rubyforge.org/api.html
I understand that at some point, 'node.h' was removed from the public
API. This is one of the reasons that most of these gems don't support
the current release. So I guess my questions are...
1. Are there ANY gems out there that have found a way to inspect the
node hierarchy in 1.9 that I might have missed?
2. The ruby-debug19 gem seems to get around the missing header files by
relying on the ruby_core_source gem. I didn't look at it in much detail,
but that gem seems to pull in the missing headers directly. That said,
if one were to take this approach, would it be feasible at all to
implement the functionality I'm looking for? Or is something missing at
a much more fundamental level? I've tried to hack a proof of concept
together (several times) and they seem to _almost_ work, but invariably
seem to end with a segfault. Even the "rb_parser_dump_tree" function in
the Ruby19 node.c gives me a segfault, though it does make it plainly
obvious that it was never meant for public consumption.
3. Is there any resource, in addition to reading the Ruby source code
itself, that might document the various macros in node.h? I've been able
to figure some of them out but others have me downright stumped. I
suspect my lack of understanding these macros may be related to the
inevitable segfaulting of my code (though that still doesn't explain the
rb_parser_dump_tree segfaults).
4. Is this really a big deal? I have some really interesting ideas for
gems that I'd dearly like to implement, but I'm afraid to bother with
them because relying on RubyNode or ParseTree would make my work totally
incompatible with Ruby 1.9. Are people actually using 1.9 in the field
yet? For example, while Rails 3 does support 1.9.2 officially, is anyone
actually planning to use it with 1.9 or will the user base be sticking
with 1.8.7 for the foreseeable future (hopefully long enough for the
missing node stuff to be added back into 1.9)?
Sorry for the novel. I guess I'm just at a point where I don't know
whether to shrug off this issue and stick with 1.8; implement it myself;
wait for someone else (or a new version of Ruby); or drop my ideas
altogether (which would be truly disappointing, but is unavoidable if
node inspection is gone forever).
Thanks for the help,
Colin MacKenzie IV