I am under the impression that passing a pointer to a static function (ie, passing a pointer to a memory address that contains the starting point of a function) is not the same as defining a method that can be called by name from C code.  I am not a C expert though.<div>
<br></div><div>Can one call fortran libraries from D?  Ie, say one wanted to use LAPACK from D?</div><div><br></div><div>Also, know of any mathematical libraries written in D (like implementations of runge-kutta, linear algebra routines and data structures, optimization or curve-fitting algorithms)?</div>
<div><br></div><div>-Mike<br><div><div>
<div><font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace"><br></font></div><br><div class="gmail_quote">On Sun, Oct 10, 2010 at 5:10 PM, Simen kjaeraas <span dir="ltr">&lt;<a href="mailto:simen.kjaras@gmail.com" target="_blank">simen.kjaras@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>On Sun, 10 Oct 2010 22:03:51 +0200, Michael Stover &lt;<a href="mailto:michael.r.stover@gmail.com" target="_blank">michael.r.stover@gmail.com</a>&gt; wrote:<br>


<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am wondering if D would be a good choice for our differential equation<br>
modeling app.  What it needs to be able to do is dynamically compile D code<br>
into a static function that can then be used to call C-code that expects a<br>
pointer to a static function.<br>
<br>
Longer description:<br>
It is a desktop app.  The user writes equations.  I&#39;d like to be translate<br>
the equations into D code, compile it, and then call C code that represents<br>
optimizing or solver procedures.  These functions expect a pointer to a<br>
static function that calculates the values of the equations, which would be<br>
the D code just compiled.<br>
<br>
Is this feasible with D2?<br>
</blockquote>
<br></div></div>
Absolutely. The dynamic compilation part is not directly supported, but<br>
possible. There are several ways of accomplishing this, from Burton<br>
Radon&#39;s (outdated, proof-of-concept only) dynamic compilation[1], to<br>
calling the C functions in the generated D code, and pipe the output<br>
where you need it.<br>
<br>
Interfacing to C is detailed on this page:<br>
<a href="http://digitalmars.com/d/2.0/interfaceToC.html" target="_blank">http://digitalmars.com/d/2.0/interfaceToC.html</a><br>
<br>
And can mostly be summarized like this:<br>
<br>
Create a D function that is callable from C:<br>
extern( C ) returnType myFunc( /* args */ ) {}<br>
<br>
Refer to a C function that is callable from D:<br>
extern( C ) returnType myFunc( /* args */ );<br>
<br>
<br>
[1]: <a href="http://members.shaw.ca/burton-radons/The%20Joy%20and%20Gibbering%20Terror%20of%20Custom-Loading%20Executables.html" target="_blank">http://members.shaw.ca/burton-radons/The%20Joy%20and%20Gibbering%20Terror%20of%20Custom-Loading%20Executables.html</a><br>


<br>
-- <br><font color="#888888">
Simen<br>
</font></blockquote></div><br></div>
</div></div>