In C, the C argument types are available at compilation time. Perhaps
we could do that in Scheme if we're interfacing to a foreign function.
Something like this:
; This is equivalent to the C prototype 'int printf (const char *format, ...);'
(define-vararg-lambda printf int "printf" ((const c-string) format))
; This is equivalent to the C statement: 'printf "A string: %s, an
int: %d, an unsigned long: %ul\n", "Hello world", -10,
18446744073709551615UL);'
(printf "A string: %s, an int: %d, an unsigned long: %ul\n" ((const
string) "Hello world") (int -10) (unsigned-long
18446744073709551615))
In this stratagy, clarity is gained by requiring the programmer to do
a little more work.
define-vararg-lambda would create a new binding construct (printf in
this case) which expects the fixed non-variable argument list as
specefied (in this case the single argument, format) followed by an
indeterminate number of argument specifiers of the form (type expr)
where type is a foreign type and expr is a Scheme expression. At its
crudest, the specifiers could be parsed into C as:
"(ctype)expr"
where ctype is the C equivalent of the foreign type specifier type.