<div dir="ltr"><div>Another thought on the semantics:</div><div>- keep init_func behavior as it is (legacy, snake_case, backward compatibility)</div><div>- passing init-func (kebab-case) new behavior: calling with the entrypoint in the same manner as</div><div>  the FFI functions: s7_scheme* sc , s7_pointer args. args being (the-passed-env &#39;args) : being either</div><div>  something or #f<br></div><div><br></div><div>Wonder if there&#39;s a point in having the called entry point also return s7_pointer. It would be</div><div>elegant though as far as consistency goes: calling any s7 FFI function as the init-func.</div><div><br></div><div>Possible use: init-func returning an environment with bindings.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 22 Oct 2020 at 22:18, Christos Vagias &lt;<a href="mailto:chris.actondev@gmail.com">chris.actondev@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>If I understood correctly you get a segfault when having the C function with 2 args (s7_scheme and s7_pointer)</div><div>but passing only s7_scheme.</div><div><br></div><div>This seems relevant: <a href="https://stackoverflow.com/questions/12572575/i-can-call-a-function-imported-with-dlsym-with-a-wrong-signature-why" target="_blank">https://stackoverflow.com/questions/12572575/i-can-call-a-function-imported-with-dlsym-with-a-wrong-signature-why</a></div><div>and particularly the answer saying</div><div>&quot;C uses cdecl call conversion (so caller clears the stack) [..]</div><div>But actually behavior is undefined&quot;</div><div><br></div><div>In any case, I&#39;m really noob in this area so that&#39;s all I can contribute.</div><br><div>So my 2 cents:</div><div>- when not having passed init_args: calling the C init_func(s7_scheme)</div><div>  (serving also as backwards compatibility)</div><div>- when init_args is present, calling init_func(s7_scheme, s7_pointer)<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 22 Oct 2020 at 21:57, &lt;<a href="mailto:bil@ccrma.stanford.edu" target="_blank">bil@ccrma.stanford.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; how does C behave if you assume that the called function has a <br>
&gt; signature<br>
&gt; of (s7_scheme* sc) and you try to pass (s7_scheme* sc, s7_pointer args) <br>
&gt; ?<br>
<br>
I tried it with the tlib example, and if you declare args in C, but<br>
don&#39;t pass them in scheme (i.e. no init_args in the environment),<br>
I get a segfault.  The other way (no args declared, but you pass and<br>
use them anyway) seems to work -- strange!  This is in gcc 10.2<br>
in Linux.<br>
<br>
</blockquote></div>
</blockquote></div>