In article <868z0irxgw.fsf / squash.oucs.ox.ac.uk>,
Simon Cozens <simon / ermine.ox.ac.uk> wrote:
>ptkwt / shell1.aracnet.com (Phil Tomson) writes:
>> I wonder if we could do this a lot faster by using swig to wrap the
>> Ruby C parser? Swig Ruby itself to make an extension for Ruby.
>
>First, SWIG is there when your own language's extension mechanism is a
>pain in the ass; Ruby's extension system is just fine, (much more
>sensible than Perl's or Python's) and so I don't think SWIG is the
>answer. (to anything) And, to be blunt, I prefered Perl's XS to SWIG.
>Your milage, of course, is sure to vary.
>
Where SWIG really shines is when you've got some substantial C or C++
library that you want to wrap pretty-much automatically (and I'm always
amazed how _little_ I have to do to use SWIG).
>Second, SWIG is particularly useful when you're trying to do cross-language
>library extensions. But we're only trying to export Ruby's AST to Ruby, so
>cross-langage concerns are irrelevant.
Well, I guess I should put it differently: We could use SWIG to wrap
ruby.h and node.h and basically do what you're trying to do, but more
automatically.
<TANGENT>
That brings up an interesting point: What if one were to wrap
Python with SWIG so that the Python interpreter was available from within
Ruby?
</TANGENT>
>
>We dealt with SWIG in Extending and Embedding Perl
>(http://www.amazon.com/exec/obidos/ASIN/1930110820/) and, to be frank,
>I really don't want to deal with it again.
What version of SWIG did you use? I guess I started out with SWIG 1.3.13
and now use 1.3.15 and have find it very easy to use. I've heard that
earlier versions were more of a pain. Also, I suspect you were using SWIG
to make Perl extensions - I've only used it to create Ruby extensions, so
perhaps there are some differences with Perl.
>Ruby's extension API,
>although I've beaten it up in the past
>(http://www-6.ibm.com/jp/developerworks/linux/001027/ruby_qa.html)
>kicks seven shades of shite out of Perl's.
Yes, Ruby's extension API is great, but when you've got lots of existing
code to wrap SWIG works great in my experience.
Phil