<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="font-family: 'Segoe UI',Frutiger,'Frutiger Linotype','Dejavu Sans','Helvetica Neue',Arial,sans-serif; font-size: 14px;">
<div class="hiri-body-wrapper" contenteditable="true">
<div>Returning an environment with bindings from init-func sounds very elegant; essentially that's what i'm doing anyway. I'm all for this as long as it doesn't prohibit adding symbols to the root environment too<br>
&nbsp;</div>
</div>
&nbsp;
<div class="hiri-extra" contenteditable="false">
<p>On 2020-10-22 20:16:53-04:00 cmdist-bounces@ccrma.Stanford.EDU wrote:</p>
<blockquote style="padding-left:10px; border-left:1px solid #ccc; margin:0">
<div>
<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>&nbsp; the FFI functions: s7_scheme* sc , s7_pointer args. args being (the-passed-env 'args) : being either</div>
<div>&nbsp; something or #f</div>
<div></div>
<div>Wonder if there'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></div>
<div>Possible use: init-func returning an environment with bindings.</div>
</div>
&nbsp;
<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:</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></div>
<div>This seems relevant: <a target="_blank" href="https://stackoverflow.com/questions/12572575/i-can-call-a-function-imported-with-dlsym-with-a-wrong-signature-why">
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></div>
<div>In any case, I'm really noob in this area so that's all I can contribute.</div>
&nbsp;
<div>So my 2 cents:</div>
<div>- when not having passed init_args: calling the C init_func(s7_scheme)</div>
<div>&nbsp; (serving also as backwards compatibility)</div>
<div>- when init_args is present, calling init_func(s7_scheme, s7_pointer)</div>
</div>
&nbsp;
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, 22 Oct 2020 at 21:57, &lt;<a target="_blank" href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>&gt; wrote:</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't pass them in scheme (i.e. no init_args in the environment),<br>
I get a segfault.&nbsp; The other way (no args declared, but you pass and<br>
use them anyway) seems to work -- strange!&nbsp; This is in gcc 10.2<br>
in Linux.<br>
&nbsp;</blockquote>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</body>
</html>