[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Varargs efficiency
- From: Rena <hyperhacker@...>
- Date: Mon, 20 Apr 2015 17:39:22 -0400
On Mon, Apr 20, 2015 at 5:38 PM, Tim Hill <drtimhill@gmail.com> wrote:
>
>> On Apr 20, 2015, at 2:11 PM, Jorge <xxopxe@gmail.com> wrote:
>>
>> On 04/18/2015 02:45 PM, Hisham wrote:
>>>>> I would doubt that using varargs as a Forth stack is the best approach.
>>>>> What’s wrong with a Lua array (aka table)?
>>>>
>>>> Lua arrays can't do nil, Lua stacks can.
>>>
>>> If you're already writing a VM to a different language, you can just
>>> map your Forth's nil to a non-nil Lua singleton.
>>
>> I'm on the same camp: null-like values that have a meaning in your business logic are not Lua nil. Nil is a language thing, not "something". If your applications has a value that can be stored and is guaranteed to exist only once then is a singleton, something like
>>
>> NULL = {} --accesible globally
>>
>>
>> Jorge
>>
>
> For one of our projects, we used a light userdata with a NULL C pointer for this purpose:
>
> lua_pushlightuserdata(L, NULL);
> lua_setglobal(L, “NULL”);
>
> This has the advantage (to my mind) of being pass-by-value and can also be persisted reasonably easily. Of course, it needs C code to create the initial value.
>
> —Tim
>
>
I like that idea, for the fact that it also works for passing NULL to
C functions. Though I'm not sure when you'd ever really need that...
--
Sent from my Game Boy.