From: John Morrison <jm@ma...> - 2005-04-24 19:38:22
Are there any "convenience" macros/functions for defining a foreign
function with a variable number of arguments, or do I need to define a
clever Lisp function?
==== John Morrison
==== MAK Technologies Inc.
==== 10 Fawcett Street, Cambridge, MA 02138
==== vox:617-876-8085 x115
On Sun, 24 Apr 2005, John Morrison wrote:
> Are there any "convenience" macros/functions for defining a foreign
> function with a variable number of arguments, or do I need to define a
> clever Lisp function?
The latter. Lisp needs to know the foreign types of all the arguments
in order to be able to pass them to C (how many bits? signed or
unsigned?), and in case of varargs this cannot be trivially done:
the information is typically encoded in the non-varargs arguments
in some ad-hoc way.
Consider printf: to be able to pass the varargs lisp would first have
to parse the control string to determine the correct types. I think the
sanest way to do this would be something like
(defmacro printf (control &rest args)
`(alien-funcall ,(parse-printf-control control) ,@args))
where PARSE-PRINTF-CONTROL returns the appropriate (EXTERN-ALIEN ...)
form for the control string. Not that it needs to be a macro, though,
just a lot simpler that way, given that we don't support ALIEN-APPLY.
-- Nikodemus Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."
Get latest updates about Open Source Projects, Conferences and News.