[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] [Chicken-bugs] #345: foreign-lambda* misfeature
From: |
Chicken Scheme |
Subject: |
[Chicken-janitors] [Chicken-bugs] #345: foreign-lambda* misfeature |
Date: |
Sat, 27 Oct 2007 13:30:46 -0000 |
#345: foreign-lambda* misfeature
------------------------+---------------------------------------------------
Reporter: elf | Owner:
Type: enhancement | Status: new
Priority: minor | Component: compiler
Version: 2.7 | Keywords: ffi, foreign-lambda, variable
substitution
------------------------+---------------------------------------------------
due to the quoting in the foreign-lambda* macro, it is impossible to
substitute platform-dependent strings. example:[[BR]]
{{{
(cond-expand
(linux
(define insstr "sendto(blah, blah, blah)"))
(macos
(define insstr "sendmsg(blah, blah, 0, blah)"))
(mingw
(define insstr "write(blah, blah, blah)"))
(else
(error "not supported")))
(define do-send
(foreign-lambda* int ((type var))
"some setup stuff"
insstr
"more stuff"))
}}}
i have also tried this with #<< and #<#, and with a string-append at the
beginning, and with creating the entire string outside of the foreign-
lambda... what finally worked is the following:
{{{
(define-for-syntax foo "y +=1 ")
(define-macro (foreign-lambda-wrap ret args . body)
`(foreign-lambda* ,ret (,@args)
,@(map (lambda (x)
(if (string? x)
x
(let ((y (eval x))
(if (string? y)
y
x))))
body)))
(define blah (foreign-lambda-wrap
<code that looks like foreign-lambda* but accepts variables for
string substitution>))
}}}
this seems like a lot of extra work to get around quoting. any
thoughts/suggestions?
--
Ticket URL: <http://trac.callcc.org/ticket/345>
Chicken Scheme <http://www.call-with-current-continuation.org/>
The CHICKEN Scheme-to-C compiler
- [Chicken-janitors] [Chicken-bugs] #345: foreign-lambda* misfeature,
Chicken Scheme <=