Boost logo

Boost Users :

From: Jeremy Pack (rostovpack_at_[hidden])
Date: 2008-08-17 13:03:31


Isaac,

On Sun, Aug 17, 2008 at 9:27 AM, Isaac Lascasas <pisiiki3_at_[hidden]>wrote:

> Hello I have the following question:
>
> If you want to make a program that will let the user write "scripts"
> directly in c++, how will you do it? I am strugling my mind these days
> looking for a solution to this problem and I want to know if boost already
> address this situation. My intuition tells me that the process will probably
> consist on invoking bjam to build a dynamic lib with the "script" and then
> call the built code in the host binary. But how can this be done keeping it
> portable and clean? Obviously it won't work if you don't have a build
> environment configured but anyway it may be a very interesting feature.
>
> Regards,
>
> Isaac Lascasas.
>

That kind of depends on what exactly you want. I put an example in
Boost.Extension that automatically compiles arbitrary code (using
Boost.Build - but you could modify it for other compilers) into a shared
library and then loads and runs it:

http://svn.boost.org/trac/boost/browser/sandbox/libs/extension/examples/runtime_compilation

I haven't gotten around to writing documentation for the example, but plan
to do it in the next few weeks. The code is relatively straightforward
though.

As far as a full scripting environment for C++, there are full libraries
that do this - but you'd have a tough time persuading me that Python or
another actual scripting language (perhaps with Boost.Python) wasn't a
better solution. I guess if all you have is a hammer...

Jeremy Pack
http://boost-extension.blogspot.com



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net