Re: Question wrt interface to Allegro

Raymond Toy <[email protected]> Wed, 10 Dec 2008 12:21:10 -0500
Newsgroups gmane.lisp.matlisp.user
Message-ID <[email protected]>
>>>>> "Nicolas" == Nicolas Neuss <[email protected]> writes:

    Nicolas> Comparing with Matlisp, I have found my bug.
    Nicolas> Nicolas Neuss <[email protected]> writes:

    >> (foreign-functions:def-foreign-call (dnrm2- "dnrm2_")
    Nicolas>                                               "dnrm2" is correct

    >> ((n :int) (x (:array :double)) (incx :int))
    >> :convention :fortran
    >> :returning :double)

    Nicolas> To make sure I understand this correctly: dnrm2_ is probably a routine
    Nicolas> suitable for calling from C (passing arrays as a pointer to values) while
    Nicolas> Allegro with convention :fortran passes arrays pointing to values-1 as is
    Nicolas> suitable for the Fortran "dnrm2".

I don't know what the :fortran convention means, but your explanation
sounds plausible.  It seems a little odd to me.  For n and incx, I can
see the :fortran convention to mean pass the address of the location
of n and incx to the routine, since that's what Fortran does
(everything is pass by reference).  Arrays are a bit trickier.  I
don't see why you want to pass the address of x-1 instead of just x.
After all, Fortran x(1) is the first element of the array, however
that array might be arranged in memory.

Ray

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/