Fork me on GitHub
  • Coverage Status

Easy to follow complete examples.

Be sure to also check out the cheatsheet.


For more examples, look at the unittests folder in source control. The unittests cover every feature of ChaiScript.
  • ChaiScript Basic Example
  • The most straightfoward example of using ChaiScript is the one from the front page. In this example we register a simple function that takes one parameter and returns a value. We then call the function from within ChaiScript and use a built in ChaiScript function to print the return value to the console.

  • ChaiScript Compiled in Stdlib Example
  • This example is like the basic example but instead of relying on a precompiled version of the ChaiScript Stdlib, it compiles it into the executable directly. This method takes considerably longer to compile, so we will use the external Stdlib for most of our examples.

  • ChaiScript Language Examples
  • Here are examples of using the ChaiScript scripting language itself, so you know what to expect. ChaiScript is inspired by ECMAScript and is designed to feel familiar and comfortable to programmers of C++.

ChaiScript Basic Example

The most straightfoward example of using ChaiScript is the one from the front page. In this example we register a simple function that takes one parameter and returns a value. We then call the function from within ChaiScript and use a built in ChaiScript function to print the return value to the console.

Note that this example relies on being able to find the ChaiScript Stdlib module, precompiled in a known location.

ChaiScript Compiled in Stdlib Example

This example is like the basic example but instead of relying on a precompiled version of the ChaiScript Stdlib, it compiles it into the executable directly. This method takes considerably longer to compile, so we will use the external Stdlib for most of our examples.

ChaiScript Language Examples

Here are examples of using the ChaiScript scripting language itself, so you know what to expect. ChaiScript is inspired by ECMAScript and is designed to feel familiar and comfortable to programmers of C++.