Suggestion - Getting Started With The API



As a completely new user of ChaiScript and a fairly new user of C++ I have found that I have a hard time getting a good overview of the implementation of ChaiScript.

For example this code:

What would be the corresponding usage in the .chai?

Maybe its only me, but I would have found it much easier to understand if there was a corresponding example of the usage in the script attached to the C++.



Well, we tried to make it so that function calls inside of script were as close to c++ as possible, with the exception that we have both dot notation object.method() and function call syntax method(object) which do the same thing.

So, taking that specific example:

using namespace chaiscript;
class MyClass {
    int memberdata;
    void method();
    void method2(int);
    static void staticmethod();
    void overloadedmethod();
    void overloadedmethod(const std::string &);
ChaiScript chai;
chai.add(fun(&MyClass::memberdata), "memberdata");
chai.add(fun(&MyClass::method), "method");
chai.add(fun(&MyClass::staticmethod), "staticmethod");

we can extend it with:

chai.add(var(MyClass()), "obj");
chai.eval("obj.method()"); // calls method
chai.eval("method(obj)"); // calls method, same as above but slightly worse performance
chai.eval("staticmethod()"); // calls staticmethod, not that since it's static there's no object to call it on

There’s also the ChaiScript cheatsheet, where I’ve been trying to put my documentation efforts lately.


I’m in great need of help on two fronts:

  1. I need users to give me EXPLICIT examples of what they’d like to see done, and I can create examples of it / add it to the cheatsheet.
  2. I need help with people creating more examples and more documentation.

I am literally the worst person in the world to create documentation for this project because I know it too well. I don’t know what’s not-obvious to the rest of the users.



This was exactly what I was looking for, a glance at this made me see the error I made in my code. With some “evals” like this it both gets clearer and get allot easier to find the example that I’m looking for.

I like this - it clarifies stuff and you haven’t used “using namespace”. I know people use it but I don’t think an example should take short cuts like this - all in the name of clarity.

At the moment I’m completely caught up in work and my own project but I will try to give you some feedback and hopefully I can provide some examples when I start documenting my project.



I agree that I don’t appreciate examples with lots of using declarations in them. Makes me confused about where things come from.