July 13, 2009 Reddit covered Release 1.0 of ChaiScript. Many things changed in the last 5 years. Features added, dependencies removed, and performance increased. With all of the changes, we decided it was time to provide a 5 year retrospective and give the world a second first-look at ChaiScript.
To start with, we’ve celebrated 5 years with a brand new website with organized examples (in progress) and documentation links: http://chaiscript.com
And a continuous integration system:
It is now trivially easy to create a function in ChaiScript and call that function from C++.
chaiscript::ChaiScript chai;
chai.eval("def func() { print(\"Hello World\"); } ");
std::function<void ()> f = chai.eval<std::function<void ()> >("func");
f(); // prints "Hello World" via the func() method defined in ChaiSript
See Also:
ChaiScript can throw exceptions which can be caught in C++ and C++ can throw exceptions which can be caught in ChaiScript.
// From C++ Example
chaiscript::ChaiScript chai;
try {
chai.eval("throw(1.0)", chaiscript::exception_specification<int, double>());
} catch (const double e) {
if (e == 1.0)
{
// success
}
}
//
// From ChaiScript Example
// multiple catches with guards on the values
try {
throw(3)
}
catch(e) : e < 3
{
// Should never get called
}
catch {
// what does get called
}
See Also:
ChaiScript can be used safely from multiple threads simultaneously, by default. It is possible to disable thread safety for enhanced performance.
See Also:
C++ libraries can be compiled as loadable modules and loaded dynamically with ChaiScript at runtime. The default behavior is for the ChaiScript standard library to now be compiled and loaded this way, reducing on re-compile times.
ChaiScript now requires only a C++11 compliant compiler, the previous boost requirement has been completely removed. It is header only (with the option of precompiling the standard library into a loadable module for reduced compile times).
Tested and supported compilers: clang 3.4+, g++4.6+, MSVC 2013+.
Depending on the test run, ChaiScript 5.3 is between 10 and 20 times faster than ChaiScript 1.0.
elseif
was split into else if
like a C++ programmer would expect it to be<<
operator support added and implemented for numericscontinue
statement support added.break
statement support addedswitch
statement support added?:
ternary operator support addedf
, ul
, u
, etc addedChaiScript currently has 322 unit tests. ChaiScript 1.0 had only 72 tests. The new testing framework is integrated with the build system and run with every check-in via Travis-CI.
Be sure to check the unit tests to verify any details about how to use ChaiScript.