[Ecls-list] Return values sometimes missing on REPL

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Thu Jun 3 20:31:03 UTC 2010


 On Thu, Jun 3, 2010 at 10:11 PM, Erik Winkels <aerique at xs4all.nl> wrote:

> > Then, you are not showing the code of the functions you define and how
> > they return multiple values. Most likely you are just using a "return
> > only-value" statement
>
> All my functions just return one value.
>
> > and do not set the counter for the returned values, which is needed by
> > ECL to know the number of returned values.
>
> Thanks, this is what I needed to know and wasn't aware of.  This,
> together with an e-mail from Polos Ruetz has solved my issue.


Great to read that. Wish I could get three months off to update that
embedding manual. Normally I recommend using embedded code written with
c-inline because there you just use @ magic to set the values. In pure C one
has to do a bit more

0) Get the environment
cl_env_ptr env = ecl_process_env();
1) Save all the output values
cl_object v1 = ...;
cl_object v2 = ...;
2) Set the values counter
env->values[0] = v1;
env->values[1] = v2;
env->nvalues = 2;

For just one return value it suffices
cl_object v1 = ...;
env->nvalues = 1;
return value;

Note the order. If you just write

env->nvalues = 1;
return whatever-c-expression

then the C expression may overwrite the value of env->nvalues.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://tream.dreamhosters.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100603/d82419c0/attachment.html>


More information about the ecl-devel mailing list