lua-users home
lua-l archive

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


Ross Bencina wrote
> On 13/06/2014 4:13 PM, Thomas Jericke wrote:
>>> I'll leave it to others to determine whether using string literals in
>>> an interface is ever good style.
>>>
>>> Ross.
>>>
>>>
>>
>> [...]
>> 
> 
> You're intentionally twisting my words.
> 
> It's one thing to be able to use a string literal, quite enough to 
> require its use in an interface.
> 
> We're not talking about module or function names here, we're talking 
> about constants that are usually integers.
> 
> Ross.

Lua's own APIs use string literals for constant 'enum' values. Some examples
of functions that do this are collectgarbage, select, type, io.type,
io.open, and coroutine.status (there are several more.)

IMO it's quite an acceptable idiom in Lua code. LÖVE[1] uses string literals
for all of its many 'enum' constants.

[1]: https://love2d.org



--
View this message in context: http://lua.2524044.n2.nabble.com/The-meaning-of-sugar-Forked-from-Re-Why-do-we-have-ipairs-tp7660591p7660695.html
Sent from the Lua-l mailing list archive at Nabble.com.