FFI: optional argument in foreign calls

Sam Steingold <[email protected]>
Newsgroups gmane.lisp.clisp.devel
Message-ID <[email protected]>
Hi,

How do we handle access to variadic foreign (C) functions?

E.g., in PARI/GP:

--8<---------------cut here---------------start------------->8---
factor(x,{lim}): factorization of x. lim is optional and can be set
whenever x is of (possibly recursive) rational type. If lim is set
return partial factorization, using primes < lim.
--8<---------------cut here---------------end--------------->8---

Is there a better way than

--8<---------------cut here---------------start------------->8---
(pari-call-out factor1 "factor" (x))
(pari-call-out factor2 "factor" (x (lim long)))
(defun factor (x &optional (lim nil limp))
  (if limp
      (factor2 x lim)
      (factor1 x)))
--8<---------------cut here---------------end--------------->8---

(I can probably wrap this into the pari-call-out macro, but the point is
-- do we really need *two* def-call-out forms?)

Thanks!

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
http://steingoldpsychology.com http://www.childpsy.net http://iris.org.il
http://jij.org http://mideasttruth.com https://ffii.org http://think-israel.org
"A pint of sweat will save a gallon of blood."          --George S. Patton

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.