lua-users home
lua-l archive

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


The parenthesis around the call were the source of my self-induced problem.
 
Although it is not a proper tail call, it does what is needed.
 
Thanks for the answer.
Al






> Date: Fri, 1 Feb 2008 15:41:25 +0000
> From: lua@corsix.org
> To: lua@bazar2.conectiva.com.br
> Subject: Re: tail calls across the C API
>
> Note the parenthesise around the call to dn.gas - these truncate the
> return values to a single value. Also be aware that a tail call does
> not occur when calling a C function; the calling function remains on
> the stack as the C function executes.
>
> On 01/02/2008, Al Pfalzgraf <alpfalzgraf@hotmail.com> wrote:
> >
> > I have a library function that has a variable number of return values. It
> > uses a Lua interface function to format its arguments and pass back the
> > return values from the library function. The intent was to use the tail
> > call behavior to move the library function's returned values back to the Lua
> > script that calls the Lua interface function.
> >
> > -- Get Attribute Single interface function for dn.gas library function
> > function gas( className, InstanceId, attrName, comment )
> > return(dn.gas( className, Node[className]["id"],
> > InstanceId,
> > attrName, Node[className][InstanceId][attrName]["id"],
> > Node[className][InstanceId][attrName]["type"],
> > comment )
> > )
> > end
> >
> > The difficulty I am having is in the return values. By stepping through
> > the library function it is known that two values are put on the stack to be
> > returned, and the library function returns the value 2. When the returned
> > values from the interface function are displayed the first is correct but
> > the second is a nil value.
> >
> > Should this work or is there a better technique to use?
> >
> > Thanks,
> > Al
> >
> > ________________________________
> > Connect and share in new ways with Windows Live. Get it now!



Climb to the top of the charts! Play the word scramble challenge with star power. Play now!