<div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Hello,</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">This might be a bit of a newbie question, but I'd like to clear this doubt. The problem I'm facing is: I want to define a function in C, and I want to pass some data to it at definition time. I thought I'd use environments for it: create a new environment to keep the data, then access it inside the function. Basically, what I'd like to do is similar to this Scheme setup:</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><span>&nbsp; &nbsp; (define (make-f)</span><div><span>&nbsp; &nbsp; &nbsp; (let ((x 1))</span></div><div><span>&nbsp; &nbsp; &nbsp; &nbsp; (lambda (y) (+ x y))))</span></div><div><br></div><div><span>&nbsp; &nbsp; (define f (make-f))</span></div><div><span>&nbsp; &nbsp; (display (f 2))</span></div><span></span></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Except f here should be a C function.</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Unfortunately, it seems C-defined functions work differently from Scheme functions. I've tried using both s7_set_curlet and s7_make_typed_function_with_environment, but no matter what I do, using s7_curlet I always get back the rootlet.</div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">So please tell me: is this actually possible? If it's not how should I rethink this problem?<br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">(As for why I need this: I was trying to write a small C++ wrapper for s7 and one feature I'd like to have is to be able to automatically define functions that aren't necessarily s7_function's, by doing the necessary conversions and then calling the original function. I tried doing that by declaring a template function that would take a function pointer, but then I can't figure out how to pass the function pointer to the s7_function I'm defining. You can see the work I've done here: <span><a target="_blank" rel="noreferrer nofollow noopener" href="https://github.com/chrg127/s7-tests/blob/52fdeb4692ac21e2be4e899c6c80db184f1d17c5/s7.hpp#L346">https://github.com/chrg127/s7-tests/blob/52fdeb4692ac21e2be4e899c6c80db184f1d17c5/s7.hpp#L346</a>)</span><br></div>