On 11/12/2007, <b class="gmail_sendername">Alceste Scalas</b> <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Il giorno mar, 11/12/2007 alle 13.33 +0100, Kenneth Lundin ha scritto:<br>> Many C-API's have callback functions. It would be nice if that could<br>> be handled as well but i am not sure if we can find a generic solution
<br>> for that.<br><br>If there is some way to call an Erlang fun() from C (i.e. from a BIF),<br>then the problem should be mostly solved: libffi allows to define<br>"closures", i.e. to dynamically create a native function that wraps a
<br>callback written in the host language.<br><br>I briefly mentioned this possibility some months ago, with examples like<br>using a C numeric library to integrate a differential equation written<br>in Erlang.<br><br>However, I was not able to find a way to call a fun() from C. Maybe I
<br>completely missed it: if it's the case, a pointer to the relevant<br>Erlang/OTP source code would be really helpful...</blockquote><div><br>Callbacks! CALLBACKS! Callbacks are the curse of the programming class. They should be avoided at all costs.
<br><br>If you have a callback how do you intend to get data in and out of them? Callbacks can't live without shared data. In which process are they to be evaluated? Everything in Erlang exists within a process.<br><br>
No, the only workable Erlang way is to replace them with messages.<br><br>Good grief,<br><br>Robert<br><br></div></div>