lua-users home
lua-l archive

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


Thanks for your help.

Regards

2012/2/8 Duncan Cross <duncan.cross@gmail.com>:
> On Wed, Feb 8, 2012 at 10:35 AM, saito yutaka <melody.pea@gmail.com> wrote:
>> Hello .
>> I am trying to read lua.c to want know how lua works.
>> And I want to ask about lua_getglobal function.
>>
>> I find a this code .
>>  lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2");
>>
>> I know that this code means get a value PROMPT("> ") or PROMPT2(">> ") .
>> But why does it use underscore [ _ ] front of global names ?
>>
>> Thanks.
>> Yutaka
>
> Starting with one underscore is just a convention to indicate
> "internal" global variables that relate to the host
> application/current context, rather than the specific program being
> run. For example _VERSION[1]. It is recommended that a piece of pure
> Lua code should avoid using this convention when defining its own
> global variables.
>
> [1] http://www.lua.org/manual/5.1/manual.html#pdf-_VERSION
>
> -Duncan
>