lua-users home
lua-l archive

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


On Mon, Sep 1, 2014 at 10:11 PM, Coda Highland <chighland@gmail.com> wrote:
> On Mon, Sep 1, 2014 at 5:29 PM, Hao Wu <wuhao.wise@gmail.com> wrote:
>>
>>
>> On Monday, September 1, 2014, Rena <hyperhacker@gmail.com> wrote:
>>>
>>> More accurately, it should return the number of values it pushed,
>>> which for most push functions will always be 1.
>>>
>>> That would simplify returning a value slightly:
>>>
>>> return lua_pushinteger(L, 42);
>>>
>>> instead of:
>>> lua_pushinteger(L, 42);
>>> return 1;
>>
>>
>> How about
>>
>> return (lua_pusxx(), 1)
>
> A clever hack, but there's a high likelihood of confusion since the
> language being interfaced with supports multiple return values,
> whereas comma operator hacks in C are considered bad form.

Huh? Comma operators are rather common, just perhaps not understood
well. Hell, this return idiom is easy to find:

return (errno = EFOO, -1);

I don't see any issue with:

return (lua_pushnil(L), lua_pushstring(L, "error"), 2);

which could easily be defined as a macro. Sure does make life easier
for the C programmer.

-- 
Patrick Donnelly