Ark
Ark copied to clipboard
Enhance module interface
What I'm talking about is this:
https://github.com/ArkScript-lang/modules/blob/master/console/src/main.cpp#L94-L101
We need a C API so that won't change, but having to know how many fields we need to allocate, and keep track of the position of each field/value (through map[index]) is very bad.
I think it's possible to do a
mapping_t* get() {
mapping_t data[] = {
{"name", function},
// ...
NULL // sentinel
};
return data;
}
but it needs tests and modifications to the VM (to avoid putting a delete), or maybe even enhance module API to add a delete_mapping(mapping_t*)
so that any module developper can choose how to deallocate memory