Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-10 Thread Graham Fawcett
On 7/10/07, felix winkelmann <[EMAIL PROTECTED]> wrote: On 7/10/07, Martin DeMello <[EMAIL PROTECTED]> wrote: > > Thanks! I was trying to use string-concatenate, but couldn't manage to > make it available at macro expansion time (is this possible?) (require-for-syntax 'sfi-13) D'oh, I forgot ab

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-09 Thread felix winkelmann
On 7/10/07, Martin DeMello <[EMAIL PROTECTED]> wrote: Thanks! I was trying to use string-concatenate, but couldn't manage to make it available at macro expansion time (is this possible?) (require-for-syntax 'sfi-13) cheers, felix ___ Chicken-use

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-09 Thread Graham Fawcett
On 7/9/07, Martin DeMello <[EMAIL PROTECTED]> wrote: Thanks! I was trying to use string-concatenate, but couldn't manage to make it available at macro expansion time (is this possible?) Try the "-X" argument to csc: csc -X byte-string-srfi-13 ... your-source-file.scm I see there is a "utf8-sr

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-09 Thread Martin DeMello
On 7/9/07, felix winkelmann <[EMAIL PROTECTED]> wrote: On 7/8/07, Martin DeMello <[EMAIL PROTECTED]> wrote: > > No, I want a C function whose body is a string generated by combining > a template and some arguments that fill in slots in the template. > (define-macro (foo name x) `(define ,name

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-09 Thread felix winkelmann
On 7/8/07, Martin DeMello <[EMAIL PROTECTED]> wrote: No, I want a C function whose body is a string generated by combining a template and some arguments that fill in slots in the template. (define-macro (foo name x) `(define ,name (foreign-lambda* void ((c-string arg)) ,(format #

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Martin DeMello
On 7/9/07, John Cowan <[EMAIL PROTECTED]> wrote: Yes, that works. However, it occurs to me that if what Martin actually wants is a C function whose body is some string whose value is not known until run-time, no amount of fiddling with macros will accomplish that; C functions have to be known b

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread John Cowan
Alex Queiroz scripsit: > I guess this is better: > > (define-macro make-foreign > (lambda (funcs) >(map > (lambda (func) > `(define ,func (foreign-lambda int ,(symbol->string func) int))) > funcs))) Yes, that works. However, it occurs to me that if what Martin actually wa

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Alex Queiroz
Hallo, On 7/8/07, Alex Queiroz <[EMAIL PROTECTED]> wrote: Ooops. Sorry, you can't do that because make-foreign is not a variable. I guess this is better: (define-macro make-foreign (lambda (funcs) (map (lambda (func) `(define ,func (foreign-lambda int ,(symbol->string

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Alex Queiroz
Hallo, On 7/8/07, Alex Queiroz <[EMAIL PROTECTED]> wrote: Usage: (map make-foreign '(func1 func2 func3)) Ooops. Sorry, you can't do that because make-foreign is not a variable. Cheers, -- -alex http://www.ventonegro.org/ ___ Chicken-users m

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Martin DeMello
On 7/8/07, John Cowan <[EMAIL PROTECTED]> wrote: Martin DeMello scripsit: > No, I don't want to pass str into the foreign function, i want str to > *be* the foreign function. That is, I want to use a variable rather > than an explicit string, or a macro that generates and inserts a > string into

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Alex Queiroz
Hallo, On 7/8/07, Martin DeMello <[EMAIL PROTECTED]> wrote: No, I don't want to pass str into the foreign function, i want str to *be* the foreign function. That is, I want to use a variable rather than an explicit string, or a macro that generates and inserts a string into the right place.

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread John Cowan
Martin DeMello scripsit: > No, I don't want to pass str into the foreign function, i want str to > *be* the foreign function. That is, I want to use a variable rather > than an explicit string, or a macro that generates and inserts a > string into the right place. Since foreign-lambda* is itself

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Martin DeMello
On 7/8/07, Alex Queiroz <[EMAIL PROTECTED]> wrote: On 7/8/07, Martin DeMello <[EMAIL PROTECTED]> wrote: > Is there any way to do this? > > (define str "hello") > (foreign-lambda* int ((int x)) str) > (define str "Hello") (define my-func (let ((foreign (foreign-lambda* int ((int x) (c-strin

Re: [Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Alex Queiroz
Hallo, On 7/8/07, Martin DeMello <[EMAIL PROTECTED]> wrote: Is there any way to do this? (define str "hello") (foreign-lambda* int ((int x)) str) (define str "Hello") (define my-func (let ((foreign (foreign-lambda* int ((int x) (c-string str)) "do stuff with x a

[Chicken-users] passing a string to foreign-lambda*

2007-07-08 Thread Martin DeMello
Is there any way to do this? (define str "hello") (foreign-lambda* int ((int x)) str) (Actually i'm trying to solve the more restricted problem of generating a call to foreign-lambda* from a macro and synthesising the string it's passed within the macro, so if the general case has no answer I'm