I’ve written some simulators in C that use Tcl and custom commands as an
embedded debugger language.
Tcl works OK, but I don’t like the language very well. It’s simple, but
not very elegant Ruby looks like a much better language.
Is there any documentation or example code showing embedding Ruby in
a C program? A Google search turns up some C++ stuff, but it didn’t
seem very helpful.
Is it possible to create multiple independent Ruby interpreter contexts?
Thanks,
Eric
[If you want to reply by private email, please remove the obvious
spam-proofing from my email address.]
Since nobody else has said anything yet, I guess I will
Is there any documentation or example code showing embedding Ruby in
a C program? A Google search turns up some C++ stuff, but it didn’t
seem very helpful.
Have you looked in the PickAxe guide? There’s a nice section there that
might answer your questions. Look under “Ruby in its Setting >>
Extending Ruby” for the goods.
Is it possible to create multiple independent Ruby interpreter
contexts?
I’m a little behind with my C ‘skillz’, but looking at the pickaxe, I
would guess no. But as I said, I’m very rusty.
Is there any documentation or example code showing embedding Ruby in
a C program? A Google search turns up some C++ stuff, but it didn’t
seem very helpful.
Have a look at README.ext in the source distribution for Ruby.
Is it possible to create multiple independent Ruby interpreter
contexts?
I’ve written some simulators in C that use Tcl and custom commands as an
embedded debugger language.
Tcl works OK, but I don’t like the language very well. It’s simple, but
not very elegant Ruby looks like a much better language.
Is there any documentation or example code showing embedding Ruby in
a C program? A Google search turns up some C++ stuff, but it didn’t
seem very helpful.
Is it possible to create multiple independent Ruby interpreter contexts?
Thanks,
Eric
[If you want to reply by private email, please remove the obvious
spam-proofing from my email address.]
Have you tried Lua instead of Tcl? I’ve heard that even pythoners think
lua is better than python for embedding. I don’t know if ruby can easily
be embedded, but I’m sure it’s the case for Lua.
Is there any documentation or example code showing embedding Ruby in
a C program? A Google search turns up some C++ stuff, but it didn’t
seem very helpful.
Lua is very easy to embed into C… There is a few good tutorials on the
subject (one of which I am writing).
If your interested in the Lua route - go to http://lua-users.org/wiki/SimpleLuaApiExample for a simple example of
embedding Lua in C.
I’ve written some simulators in C that use Tcl and custom commands as an
embedded debugger language.
Tcl works OK, but I don’t like the language very well. It’s simple, but
not very elegant Ruby looks like a much better language.
Is there any documentation or example code showing embedding Ruby in
a C program? A Google search turns up some C++ stuff, but it didn’t
seem very helpful.
Is it possible to create multiple independent Ruby interpreter contexts?
Thanks,
Eric
[If you want to reply by private email, please remove the obvious
spam-proofing from my email address.]
Have you tried Lua instead of Tcl? I’ve heard that even pythoners think
lua is better than python for embedding. I don’t know if ruby can easily
be embedded, but I’m sure it’s the case for Lua.
I’ve written some simulators in C that use Tcl and custom commands as
an embedded debugger language. Tcl works OK, but I don’t like the
language very well. It’s simple, but not very elegant
Have you tried Lua instead of Tcl? I’ve heard that even pythoners
think lua is better than python for embedding. I don’t know if ruby
can easily be embedded, but I’m sure it’s the case for Lua.
Actually I have looked at Lua. The syntax makes it less than
ideally suited for my reqirement. For instance, when a user wants
to examine a dozen memory locations starting at octal location 2074, he
or she will want to type
examine 02074 12
or maybe
examine 02074, 12
but not
examine (02074, 12)
The first syntax is easily achieved with Tcl but as far as I can tell,
only the third works in Lua. It looks like the second and third should
both work in Ruby.
I wrote:
Is there any documentation or example code showing embedding Ruby in
a C program?
I just discovered the “Extending Ruby” chapter of “Programming Ruby”,
and it seems to have the information I was looking for.
I wrote:
Is it possible to create multiple independent Ruby interpreter contexts?
Is it possible to create multiple independent Ruby interpreter contexts?
I still haven’t found any way to do that.
I’m a bit out of my element on this one, but I don’t believe it is
generally possible. I have seen somewhere, although I unfortunately
have no reference, that it is also between impractical and impossible
to “reset” an embedded interpreter by destroying and recreating an
embedded instance. Finally, since Ruby does not use native threading,
embedded scripts may not be properly discouraged from using broken
threading constructs. All of these factors (plus regex licensing,
last I heard) seem to strongly encourage extending over embedding.
The biggest drawback would be the case where you wish to make multiple
scripting interfaces/languages avaliable to your application.
If your app supports Windows, COM is almost certainly your best
option. I don’t think there is anything else as elegant or effective.