"There are eight basic types in Lua: nil, boolean, number, string,
function, userdata, thread, and table.
...
Tables, functions, threads, and (full) userdata values are objects:
variables do not actually contain these values, only references to
them."
-- http://www.lua.org/manual/5.1/manual.html#2.2
My layman interpretation of the second sentence above was that
variables
thus *do* 'contain' values that are not object types. (I realize that
this is technically a logical fallacy, but a reasonable interpretation
of the intent.) Thus, I had thought that the code...
local a = "foo"
local b = "foo"
local c = b
...meant that 3 strings were allocated in memory internally, one to be
contained.
Are 3 strings allocated and maintained internally? (Each assignment of
a
non-object value copies it 'into' the variable.)
Or is it 2? (One for each string literal, with the latter shared by 'b'
and 'c'.)
Or is it 1? (Are Lua's internals tricky enough that they 'hash' a
string
and only allocate memory for each unique sequence?)