ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Alan Braslau <alan.braslau@cea.fr>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: LuaTeX 1.0.3 announcement
Date: Sat, 18 Feb 2017 09:03:05 -0700	[thread overview]
Message-ID: <20170218090305.6760f714@zoo.hsd1.co.comcast.net> (raw)
In-Reply-To: <CAG5iGsCUxoHLUCwuUg=p7==7UZRPOsiB3kQiGAewwwur9MJskQ@mail.gmail.com>

On Sat, 18 Feb 2017 14:59:14 +0100
luigi scarso <luigi.scarso@gmail.com> wrote:

> On Sat, Feb 18, 2017 at 2:27 PM, Henri Menke <henrimenke@gmail.com>
> wrote:
> > On 02/18/2017 09:42 AM, luigi scarso wrote:  
> >> On Sat, Feb 18, 2017 at 9:11 AM, Henri Menke
> >> <henrimenke@gmail.com> wrote:  
> >>> On 02/17/2017 08:57 PM, luigi scarso wrote:
> >>> How can I use the FFI?  There is nothing in the latest docs.
> >>> Thanks for all the efforts!  
> >> luatex ffi is beyond the "experimental state", and aims to  be
> >> compatible with luatexjit ffi.  
> >
> > So it has the same interface?  There seems to be no documentation
> > about it in the most recent manual from luatex.org  
> yes, "aims to be compatible" means same interface and functionality,
> but there is still lot of work to do,
> apart the dynamic  loading of the library and the C parser.
> But it's usable for testing.
> 

Luigi has shown me a simple and useful application of ffi:

\startluacode

ffi=require("ffi")
ffi.cdef[[
double j0(double x);
double j1(double x);
double jn(double x);
-- ...
]]

\stopluacode

These libm functions can then be used in lua as:

ffi.C.j0(x)

for example.

In my case, I pass them to MetaPost as:

\startMPdefinitions

vardef jzero primary x =
  scantokens(lua("mp.quoted(ffi.C.j0(" & decimal x & "))"))
enddef ;

\stopMPdefinitions

This experimental code appears to work quite well.

Thank you Luigi and Hans!

Alan
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2017-02-18 16:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 19:57 luigi scarso
2017-02-18  8:11 ` Henri Menke
2017-02-18  8:42   ` luigi scarso
2017-02-18 13:27     ` Henri Menke
2017-02-18 13:52       ` Hans Hagen
2017-02-18 13:59       ` luigi scarso
2017-02-18 16:03         ` Alan Braslau [this message]
2017-02-18 14:08       ` Hans Hagen
2017-02-18 23:34 Akira Kakuto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170218090305.6760f714@zoo.hsd1.co.comcast.net \
    --to=alan.braslau@cea.fr \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).