lua-users home
lua-l archive

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


On 13/06/2014 12:15 PM, Coda Highland wrote:
On Thu, Jun 12, 2014 at 7:12 PM, Rena<hyperhacker@gmail.com>  wrote:
>On Wed, Jun 11, 2014 at 10:13 PM, Ross Bencina<rossb-lists@audiomulch.com>
>wrote:
>>
>>The problem is in Lua (unless I'm missing something), you don't have
>>symbolic constants

[snip]

>Well, Lua *does* have constants:

String literals are *not* symbolic constants.


>switch event.type
>   case 'move' print("I was moved to", event.x, event.y) break
>   case 'resize' print("I was resized to", event.w, event.h) break
>   case else print("I don't know how to deal with", event.type)
>end
>
And thanks to string interning, these are as fast as integer comparisons.

That doesn't help you when you already have an integer.

I'll leave it to others to determine whether using string literals in an interface is ever good style.

Ross.