katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
92 stars 6 forks source link

Simplified API #11

Closed katsaii closed 2 years ago

katsaii commented 2 years ago

The catspeak_execute and catspeak_compile_buffer functions are useful, but becomes a bit exhausting for simple "compile-and-execute" use cases, such as loading an initialisation script from a file that only gets executed once.

Consider adding a new catspeak function, which should encapsulate this behaviour:

catspeak("1 + 2").andThen(function(result) {
  show_message(result);
});

If the first argument is not a string, then it is assumed to be a buffer:

catspeak(buff).andThen(function(result) {
  show_message(result);
});

The second parameter to this function will determine the namespaces to use when resolving global constants. For example, adding a particle function to a namespace:

catspeak_prelude_add_function("part", "create", part_type_create);

and then making that namespace visible to the compiler:

catspeak("part::create()", "part").andThen(function(result) {
  show_message(result);
});

Syntax to be decided.

katsaii commented 2 years ago

Closed because of #12.