ChaiScript is the first and only scripting language designed from the ground up with C++ compatibility and modern design in mind. It is an ECMAScript-inspired, embedded functional-like language.
ChaiScript is licensed under the BSD license.
ChaiScript is the first and only scripting language designed from the ground up with C++ compatibility and modern design in mind. It is an ECMAScript-inspired, embedded functional-like language.
ChaiScript is licensed under the BSD license.
Version: 3.1.0 Released: 6/18/2011
I've encountered several strange errors and warnings compiling very simple toy program like this:
#include
#include
using namespace chaiscript;
using namespace std;
int main()
{
ChaiScript chai;
int i = 100;
chai.add(var(i), "i");
double d = chai.eval("function(3, 4.75);");
cout << d << endl;
}
I compile it with this command line:
g++ -I/home/semen/install/chaiscript-3.0.0-Source/include/ -I/home/semen/install/boost-trunk/ -DCHAISCRIPT_NO_THREADS 1.cpp
And get an error:
In file included from /home/semen/install/chaiscript-3.0.0-Source/include/chaiscript/dispatchkit/boxed_value.hpp:12:0,
from /home/semen/install/chaiscript-3.0.0-Source/include/chaiscript/dispatchkit/dispatchkit.hpp:22,
from /home/semen/install/chaiscript-3.0.0-Source/include/chaiscript/chaiscript.hpp:561,
from 1.cpp:2:
/home/semen/install/chaiscript-3.0.0-Source/include/chaiscript/dispatchkit/../chaiscript_threading.hpp:13:66: note: #pragma message: ChaiScript is compiling without thread safety.
/tmp/ccqTtt0u.o: In function `chaiscript::detail::Loadable_Module::DLModule::DLModule(std::basic_string, std::allocator > const&)':
1.cpp:(.text._ZN10chaiscript6detail15Loadable_Module8DLModuleC2ERKSs[_ZN10chaiscript6detail15Loadable_Module8DLModuleC5ERKSs]+0x28): undefined reference to `dlopen'
1.cpp:(.text._ZN10chaiscript6detail15Loadable_Module8DLModuleC2ERKSs[_ZN10chaiscript6detail15Loadable_Module8DLModuleC5ERKSs]+0x50): undefined reference to `dlerror'
/tmp/ccqTtt0u.o: In function `chaiscript::detail::Loadable_Module::DLModule::~DLModule()':
1.cpp:(.text._ZN10chaiscript6detail15Loadable_Module8DLModuleD2Ev[_ZN10chaiscript6detail15Loadable_Module8DLModuleD5Ev]+0x17): undefined reference to `dlclose'
/tmp/ccqTtt0u.o: In function `chaiscript::detail::Loadable_Module::DLSym (*)()>::DLSym(chaiscript::detail::Loadable_Module::DLModule&, std::basic_string, std::allocator > const&)':
1.cpp:(.text._ZN10chaiscript6detail15Loadable_Module5DLSymIPFN5boost10shared_ptrINS_6ModuleEEEvEEC2ERNS1_8DLModuleERKSs[_ZN10chaiscript6detail15Loadable_Module5DLSymIPFN5boost10shared_ptrINS_6ModuleEEEvEEC5ERNS1_8DLModuleERKSs]+0x34): undefined reference to `dlsym'
1.cpp:(.text._ZN10chaiscript6detail15Loadable_Module5DLSymIPFN5boost10shared_ptrINS_6ModuleEEEvEEC2ERNS1_8DLModuleERKSs[_ZN10chaiscript6detail15Loadable_Module5DLSymIPFN5boost10shared_ptrINS_6ModuleEEEvEEC5ERNS1_8DLModuleERKSs]+0x5f): undefined reference to `dlerror'
collect2: ld returned 1 exit status
For me the only way to overcome this is to use the CmakeLists file from Chaiscript installation and adapt it, then it works. But why it doesn't work from command line? What is the correct command line?
Then i've found that ChaiScript somehow interferes with Eigen linear algebra library (http://eigen.tuxfamily.org/), which I use extensively. Here is the test case:
#include
#include
#include
using namespace chaiscript;
using namespace std;
int main()
{
ChaiScript chai;
}
It gives A LOT of strange warnings from Eigen of this kind:
...
/home/semen/install/eigen-3.0.0/Eigen/src/Core/BandMatrix.h:284:7: warning: declaration of ‘subs’ shadows a member of 'this'
/home/semen/install/eigen-3.0.0/Eigen/src/Core/BandMatrix.h:284:7: warning: declaration of ‘supers’ shadows a member of 'this'
...
This is weird and should not go this way I guess (a bug?).
An finally - this forum does not show captcha image in Firefox 4, so I can't login and have to go for Opera.
Sincerely,
Semen
Testing captcha
It should be fixed now.
Library flag
Looks like you also want to add a -ldl to this to include the library for dynamically loading libs.
g++ -I/home/semen/install/chaiscript-3.0.0-Source/include/ -I/home/semen/install/boost-trunk/ -ldl -DCHAISCRIPT_NO_THREADS 1.cpp
Thank you very much! This
Thank you very much! This solved both issues! I guess you should add this to the getting started tutorial because this is really puzzling when happens.
One more question. Is it possible to expose overloaded operators to work with user classes in the script?
Sorry about the captcha
Sorry about the captcha problem, it seems to be an error in the https cert used by captcha, it's on my todo list to fix that.
Regarding operators, it's pretty simple to overload them.
Basically, they exist like any other function in ChaiScript.
I'll make a note to get that getting started compilation
-ldlfixed.Please let us know what your project is, we'd love to get it added to our gallery of projects using ChaiScript.
-Jason
The problem with my project
The problem with my project is that I use Eigen vectors extensively and the scripting language should be capable of doing basic vector operations (add, substruct, scale, vector-matrix multiply etc.). Eigen uses some template magic for this, which can not be exposed to the script. So far I use python and numpy with hand-made converters Eigen<->numpy. Chaiscript is not capable of any vector algebra itself (as far as I understand), so I'll have to write and expose a wrapper class. Embedding Python is a pain of course, but maintaining wrapper class is also a pain and I don't know yet what is less painful :)
No, no built-in ChaiScript
No, no built-in ChaiScript support for vector algebra.
I would like to ask why the template magic cannot be exposed to the script? Of course, no scripting language can directly support templates because the templates need to be compiled by the compiler, so they must first be instantiated then exposed.
The question is, why can't you just expose the template functions you need, skipping the need for the wrapper class?
As far as understand (I'm not
As far as understand (I'm not a bit expert in advanced templates) the problem is in expression templates, which are used in Eigen. There is no such thing as "normal" operator+, so nothing to expose. So far I failed to expose any Eigen methods, which use expression templates.
Btw, the idea of boost::python converters is really good and it would be very useful to have something like this in Chaiscript. Imagine that I have a function
I can't expose Eigen::Vector3f itself for whatever reasons, so I have to make a wrapper class and also to make wrappers for all functions using Vector3f, which is a nightmare. In boost::python I can write a converter, which automatically translates Vector3f to whatever I need in the script and vice versa.
Sorry, I forgot code tags, so
Sorry, I forgot code tags, so includes are missed. The codes are:
#include <chaiscript/chaiscript.hpp> #include <iostream> using namespace chaiscript; using namespace std; int main() { ChaiScript chai; int i = 100; chai.add(var(i), "i"); double d = chai.eval("function(3, 4.75);"); cout << d << endl; }----------
#include <chaiscript/chaiscript.hpp> #include <iostream> #include <Eigen/Core> using namespace chaiscript; using namespace std; int main() { ChaiScript chai; }