lua-users home
lua-l archive

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


Can you save a state and revert a machine to a previous state (like in VMs)? Or is the whole thing part of a state machine?

If not, "state" doesnt quite cut it. "lua_Instance" would IMHO be a better name.

I disagree with the "PIET" argument. If you are not doing that one-time-throw-away-script, coding is at least as much communicating with other humans as it is communicating with the computer. So anyhting *I* remember will is not a good point.

Is it worth changing it? I don't know, I like renaming things when I figured out a better caption for something thats more precise or to now fit better in an overall naming scheme.

Albeit I can fully undestand if someone says, a rename is definitely not worth the breakage when the library binding would be called lua_newinstance instead of newstate.


On Tue, Aug 26, 2014 at 1:57 PM, Thiago L. <fakedme@gmail.com> wrote:

On 26/08/14 06:18 AM, Duncan Cross wrote:



On Tue, Aug 26, 2014 at 10:15 AM, Duncan Cross <duncan.cross@gmail.com> wrote:
On Mon, Aug 25, 2014 at 8:01 AM, Thomas Jericke <tjericke@indel.ch> wrote:
On 08/25/2014 02:56 AM, Patrick Donnelly wrote:
On Sun, Aug 24, 2014 at 4:02 PM, Thijs Schreijer
<thijs@thijsschreijer.nl> wrote:
As "lua_State" not actually refers to a state, but to a thread or an execution stack, could it be renamed? To something that properly reflects what it is?

I suspect that the name was introduced before coroutines were added, which meant that a state and a thread were pretty much the same thing then.
+1 for lua_Thread.


I don't really get the use of the word 'thread' in the C API, they are called "coroutines" in the Lua library.
--
Thomas


It's because not all threads are coroutines. Every Lua state automatically has a "main" thread, and this thread is not a coroutine. It cannot be suspended.

For example, compare the C API function lua_pushthread(L), which will always push a thread object even if it is the main thread, with the Lua library function coroutine.running(), which will return nil if the current thread is the main thread.

-Duncan
 
Unless things have changed in the most recent version(s), in which case: for historical reasons. :)

-Duncan

coroutine.running() returns the main thread in lua 5.2+

Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> =coroutine.running()
thread: 0xc8b010    true
>