chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] why Chicken?


From: felix winkelmann
Subject: Re: [Chicken-hackers] why Chicken?
Date: Fri, 2 Feb 2007 14:07:56 +0100

On 2/2/07, Tony Sidaway <address@hidden> wrote:

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.


Wouldn't this be sufficient: http://callcc.org/$ ?


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]