munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.5k stars 1.01k forks source link

Calling user external functions from a script. #1030

Open jenya7 opened 2 years ago

jenya7 commented 2 years ago

In my embedded projects (Linux or ARM) running a script itself has a little value to me. I wonder if I can invoke my functions from a script like

var sens1_val = 0 ; var sens2_val = 0 ;

void main() { sens1_val = GetDataByValType(1, SENS_VAL_TYPE_TEMP) sens2_val = GetDataByValType(2, SENS_VAL_TYPE_HUM)

if ( sens1_val > 30.5 and sens2_val > 60)
    Out(1, true);

}

Here GetDataByValType and Out(1, true); the functions that communicate in outside world.