Re: [Chicken-users] pass by value and callbacks
Hello pluijzer As i know chicken didnt have pass-by-value FFI type. This is little bit verbose workaround. Note that you should use foreign-safe-lambda for callbacks from C. (import scheme chicken foreign) # typedef struct { int x, y; } Point; typedef void (*SomeCallbackFuncType)(Point point); void someFunc(SomeCallbackFuncType callback) { Point p = {1, 1}; callback(p); } static void callbackFunctionJumper(Point point) { callbackFunction(point); } # (define-external (callbackFunction (c-pointer point)) void (print Hello from callback!)) ((foreign-safe-lambda* void () someFunc(callbackFunctionJumper);)) Hello chickeners, I am trying to wrap a function that accepts a function pointer with an argument to a struct passed by value. I don't know how to do this (and fear it is not possible) but maybe somebody else has a solution. A little example of what I mean: # typedef struct { int x, y; } Point; typedef void (*SomeCallbackFuncType)(Point point); void someFunc(SomeCallbackFuncType callback) { Point p = {1, 1}; callback(p); } # (define-external (callbackFunction (??? point)) void (print Hello from callback!)) ((foreign-lambda void someFunc c-pointer) #$callbackFunction) I don't actually need the the value of the object in my callback. Maybe that helps. Thank you in advance, Pluijzer ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Review my Caesar Cipher?
On Tue, Mar 11, 2014 at 9:20 PM, Daniel Carrera dcarr...@gmail.com wrote: On 11 March 2014 12:41, Alex Shinn alexsh...@gmail.com wrote: Chibi has string-map in (chibi string). But actually, if you're aiming for R7RS support then string-map is in (scheme base). Just replace the cond-expand with: (import (scheme base)) Hmm... sadly, (import (scheme base)) fails with Chicken and Gauche. I am also having a hard time figuring out how to print with Chibi. I tried the manual, and I tried (print), (printf) and (display). Then change your cond-expand to: (cond-expand ((or chicken gauche) ; compatibility (use srfi-13)) (else ; R7RS (import (scheme base) (scheme write R7RS puts display in (scheme write), because it typically falls back to write for non-char/strings, and because write is actually a fairly large and complicated procedure not needed by most libraries. However, write-char, write-string and newline are all in (scheme base) so you could just use write-string here. You can also (import (scheme r5rs)) to get all of the R5RS bindings except transcript-on/off. -- Alex ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users