On Mon, Apr 1, 2013 at 9:40 AM, Juan Jose Garcia-Ripoll <juanjose.garciaripoll@gmail.com> wrote:
I know, but I do not have C++11 in all the machines I work with.

Despite this, I have managed to advance a bit without cluttering the code too much. A few tenths of lines more and the interface can now handle functions with reference arguments, working as SBCL does: the I/O arguments are returned as extra return values.

An example of the code that can be written is below. Still, there are things to be handled, like functions with void return values, but a minimal portable and very understandable interface can be built using Christian's idea

An excerpt of test/test_defun.cc

  int f_int_int_ref(int &i) {
    int output = i + 1;
    i = i + 2;
    return output;

  TEST(Defun, DefunIntRef1) {
    /* Defines a function that returns two values: "output"
     * and the value of the reference. */
    defun("FOO", f_int_int_ref);
    ASSERT_T(eval_string("(EQUAL (MULTIPLE-VALUE-LIST (FOO 0)) '(1 2))"));
    ASSERT_T(eval_string("(EQUAL (MULTIPLE-VALUE-LIST (FOO 1)) '(2 3))"));
    ASSERT_T(eval_string("(EQUAL (MULTIPLE-VALUE-LIST (FOO 2)) '(3 4))"));

Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)