News for hackers. Stuff that matters.
Re:Scriptable Operating Systems with Lua [pdf] by anonymoushn on Tuesday September 30, 2014 @08:43PM (#8392254)
What's the symbol type for, and is Lua incapable of expressing it?
Re:Scriptable Operating Systems with Lua [pdf] by ufo on Wednesday October 01, 2014 @10:41AM (#8394714)
Symbol types[1] are useful for storing identifiers, method names or enums. They are common in LISPs and in Lua you use (immutable) strings for a similar purpose[2].

The main advantage of symbol types are that they have a more restricted API than strings and that they might be more efficient (integer vs string representation)

[1] https://en.wikipedia.org/wiki/Symbol_%28Lisp%29

[2] For example, in Lua obj.foo is syntactic sugar for obj["foo"], similarly to Javascript.

Re:Scriptable Operating Systems with Lua [pdf] by hisham_hm on Wednesday October 01, 2014 @01:05PM (#8396006)
Since you pointed out that Lua strings are immutable you're aware of what I'm about to say, but just to make it explicit:

The efficiency argument is a common one for symbols in general, but in Lua it doesn't really hold because string comparison has constant cost (ie, it's a simple pointer test, since strings are immutable).

Re:Scriptable Operating Systems with Lua [pdf] by to3m on Wednesday October 01, 2014 @03:00PM (#8396886)
Immutable and interned!

(This may or may not be an issue, but it still offended me somewhat, since you're getting all of the compile-time cost at runtime, combined with none of the expressiveness. Not a tradeoff that impresses me, personally, even if the speed is fine - but it takes all sorts.)