libera/#ecl - IRC Chatlog
Search
7:33:41
jackdaniel
psilord: that's the interface you are looking for, yes. note that return values are a subject of certain conventions. most notably the number of returned values is set in the environment
7:34:21
jackdaniel
i.e (env)->nvalues = 2; (env)->values[0] = val1; (env->values[1] = val2; return val1;
7:35:18
jackdaniel
it is not to say that you can't register an arbitrary function to def_cfunction, but then the last set value of nvalues and values will pertain
7:35:50
jackdaniel
in that case you may be surprised that (let ((foo (my-c-fun))) ...) for some reason returns NIL
8:21:55
selwynning
i suspect that the sandboxed target will simply be the wasi target after having wasi calls stubbed out
9:13:52
psilord
Another question I had is how do I handle signalling a condition if I decide the arguments passed to the C function aren't correct? (like wrong type, etc). Supre I can check it with ECL_FIXNUMP(x) and all that, but if that is wrong, how do I signal the confition? Do I construct one and pass it back via the cl_object return value and the ECL runtime figures out it is actually a signaled condition?
9:19:39
jackdaniel
psilord: generally speaking you have functions like FEprogram_error etc (see src/c/error.d)
9:21:34
jackdaniel
as of how this works - if we take a reductionist perspective it boils down to setjmp and longjmp with necessary machinery to retain computation semantics
9:22:04
jackdaniel
from c code you have HANDLER_CASE_BIND and HANDLER_RESTART_BIND macros (both are documented in the manual)
9:23:14
jackdaniel
btw, regarding C functions that may but doesn't have to set nvalues and values[] - mind that this way you can implement special operators without touching return values set by (for example) one of forms passed as arguments