About ChaiScript

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.

Download

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)

Method with a large number of parameters

I try to add type method with 15 parameters and see an error:

chaiscript/include/chaiscript/dispatchkit/register_function.hpp:51: ошибка: invalid use of incomplete type 'class boost::function<void(Object&, std::basic_string<char>, int, int, int, int, int, int, std::basic_string<char>, int, int, bool, bool, bool, std::basic_string<char>, std::basic_string<char>)>'

Did i something wrong? or its just impossible?
please help

PS: Sorry for bad English

The problem is likely because

The problem is likely because boost::function only supports up to 10 parameters. That's a limitation we cannot get around. I see in a later post that you are using the C++11 version (5.0.0) also. That should not have the same limitation.

-Jason

Oh, by the way - is it real

Oh, by the way - is it real to add global non constant variables?
i ask becouse in some cases i need to run chai script from another chai script use some "execScript" function, that exported in chaiscript. And when i exec script in script i lost non global variables...
I try to add to ChaiScript class "add_global" method:

    ChaiScript &add_global(const Boxed_Value &t_bv, const std::string &t_name)
    {
      m_engine.add_global(t_bv, t_name);
      return *this;
    }

and add to engine:

        void add_global(const Boxed_Value &obj, const std::string &name)
        {
            validate_object_name(name);
 
            chaiscript::detail::threading::unique_lock<chaiscript::detail::threading::shared_mutex> l(m_global_object_mutex);
 
            m_state.m_global_objects.insert(std::make_pair(name, obj));
        }

It's work, but i think it's an ubly hack =)

We initially did not what to

We initially did not what to allow globals at all in ChaiScript but decided to because we acknowledged that things like enumerations need to sometimes be exported.

ChaiScript supports threading but does not support explicit locking. If we allow globals that are non-const it opens up some possible threading issues to the user.

Besides, it's generally agreed globals are a bad idea and we are trying to encourage good ideas :)

Can you have the values you want generated by your script returned from functions?

-Jason

Return they from function an

Return they from function an alternative, but what if i didn,t use threading? In that case use global non const variables is justified?

I'm still not going to

I'm still not going to support adding of global non-const values in the official ChaiScript. The only reason we allow it at all is to support things like enumeration types.

Globals are widely accepted as being a bad idea in general.

-Jason

[CLOSED]

Sorry, I must check twice. First i use 4.0.0 version and have that error, but later i clone git repo and latest commits and forget to try this again.

Support ChaiScript by sharing it with your friends: