[CM] Possible bug in s7_values
Woody Douglass
wdouglass at carnegierobotics.com
Thu Apr 21 11:57:31 PDT 2022
The program that i'm maintianing with s7 scheme incorporates libev as
an event loop. I wrote a cooperative version of `map` that allows the
loop to cycle in between calls to the procedure passed in, which keeps
other events (like user input) from being starved by long calculations
-- my "cooperative map" wasn't handling functions that return multiple
values properly until i wrapped the result up in `list-values`, like i
sent in my last email.
It would be nice if there was an interface to see if a procedure
returned more then one value when called from C.
Thanks,
Woody Douglass
On Thu, 2022-04-21 at 11:02 -0700, bil at ccrma.Stanford.EDU wrote:
> The printer includes "values" when it is asked to print a list
> of values that was not spliced into a caller's argument list.
> It is just trying to be helpful. In the second ("v") case,
> it gets the values list unhandled by anything, so it includes
> "values" as a sort of warning.
>
> s7_values gives a way to return multiple values from a function
> defined in C to a Scheme function (see example below). It is
> often equivalent to (apply func (list...)). You can capture
> the values in a list if you want.
>
> list-values is a special version of list that splices out
> (values) (i.e. values without any arguments). This is expected
> in quasiquote, but in s7 other functions (e.g. map) also use it.
>
>
> static s7_pointer vals(s7_scheme *s, s7_pointer args)
> {
> return(s7_values(s, args));
> }
>
> int main(int argc, char **argv)
> {
> s7_scheme *s = s7_init();
> s7_define_function(s, "vals", vals, 0, 0, true, NULL);
> s7_pointer e = s7_eval_c_string(s, "(+ (vals 1 2 3))");
> s7_display(s, e, s7_current_output_port(s));
> s7_newline(s, s7_current_output_port(s));
> }
>
>
> What are you actually trying to do?
>
More information about the Cmdist
mailing list