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.
Due to an increased release schedule, and the nature of ChaiScript being a header-only library, binary releases will be made less often. Previous releases can be found on github.
Version: 4.2.0 Released: 12/1/2012
(Requires Boost)
Source (tar.bz2)
Source (zip)
Version: 5.2.0 Released: 12/1/2012
(Requires C++11 Compiler)
Source (tar.bz2)
Source (zip)
I try to add some method with unsigned int parameter, later a cant call it from chai script. But if i change parameter from "unsigned int" to "int" it works.
Not work:
class Inventory { ... void addItemByName(string name, unsigned int count); ... }
work:
Not work:
class Inventory { ... void addItemByName(string name, int count); ... }
adding:
...
chai.add(fun(&Inventory::addItemByName), "addItem");
...chaiscript:
... inventory.addItem("Item name", 1); ...
Is there a way to add function with unsigned int parameter?
PS: Sorry foe bad English
The function is working fine,
The function is working fine, the problem is that ChaiScript is very strongly typed and does not do any
inttounsigned intconversions automatically.You can either expose the method as if it has a signed int:
OR
You can call it and use a ChaiScript cast to unsigned:
-Jason
Do you plan to support
Do you plan to support automatic conversions? Or is it one of the feature of ChaiScript?
The first thing I thought, it's situation like this:
c++:
If i export this functions, i can do like this:
but can't do:
and i must do:
I think it's a little uncomfortable. But this is my personal opinion. How do you look at this problem?
P.S. Sorry for bad English
It is cumbersome, I agree,
It is cumbersome, I agree, but ChaiScript has a few unique challenges, trying to straddle the line between C++ and Scripting Land.
If we support automatic conversions, it makes the choice as to which version of the function to call much more complicated (say, if you had both signed and unsigned versions of a method). It also adds a fair bit of overhead to make that determination at runtime.
It might happen in the future, but it is pretty low priority right now.
-Jason
On a side note, if you would
On a side note, if you would like to support just one function to make it more accessible to your users (or yourself) you could add a ChaiScript overload:
This will work with any value that can be converted to an
unsigned_int. It will take lower priority over the strongly typed C++ version you registered so will only add overhead in the case where you call it with anything other than an unsigned_int.-Jason
I'll wait for the
I'll wait for the implementation of this feature =)
By the way, can I also override the class method?
And do you have a plan of work for which you are moving? =)
Can we see something like what to expect in the new versions? =)