Left side of assignment in previous example, that is the assumption “What should "x=x-1" mean then?”, has an inherent bug. The variable "x" is not a number.
Assume you have
local h = {}
local mt = {}
function mt:__call( arg ) return arg end
setmetatable( h, mt )
return h
then
foo = foo( -1 ) -- reassign foo = -1
foo = foo 1 -- unexpected symbol foo = foo -1 -- attempt to perform arithmetic on local foo = foo - 1 -- attempt to perform arithmetic on local
Next call after reassign will fail. Third and fourth statement can be fixed with a sub and add metamethod.
The second statement fails due to the parser, and can't be fixed.
Now rewrite as similar and syntactically valid statements with strings
foo = foo( 'bar' ) -- reassign foo = 'bar'
foo = foo 'bar' -- reassign foo = 'bar' foo = foo .. 'bar' -- attempt to concatenate local
Next call after reassign will fail. Third statement can be fixed with a concat metamethod.