chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] MV in foreign-lambdas


From: Peter Keller
Subject: Re: [Chicken-users] MV in foreign-lambdas
Date: Mon, 7 Oct 2002 15:30:16 -0500
User-agent: Mutt/1.2i

On Mon, Oct 07, 2002 at 09:06:52PM +0100, address@hidden wrote:

> Perhaps instead of saying "#:out <type>" you'd say "(<type> result)"
> or something. I don't know which would be best.

I disagree with this idea, here's why:

Suppose this function:

int foo(int *qux)
{
        int old = *qux;
        *qux += 1;
        return(old);
}

The caller:
void bar(void)
{
        int goo = 42;
        int feh;

        feh = foo(goo);
        printf("feh is 42: %d\n", feh);
        printf("goo is 43: %d\n", goo);
}

Now, given the semantics of C, the *meaning* of the above is to increase
the caller's copy of the variable pointed to by foo by one, and return
the old value.

The question is: Do you want your multiple value system to mimic pass
by reference(which it doesn't), or do you just strictly want more than
one return value?

The paradox with the above question is that since C doesn't have
multiple return values, the *only* way you can get multiple values back
is through the pass by reference mechanism. Because these two concepts
are not seperated in C, you cannot seperate them in the scheme interface
to it either.

-pete






reply via email to

[Prev in Thread] Current Thread [Next in Thread]