lua-users home
lua-l archive

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


thank you very much!

>> if we try to assign
>>
>>   b[nil] = {}
>>
>> then we get error 'table index is invalid', but if we try
>>
>>    if b[nil] == nil then
>>       ...
>>    end
>>
>> no error is raised. Is it correct behaviour?

AB> Yes.  The manual says:

>> An access to an indexed variable t[i] is equivalent to a
>> call gettable_event(t,i).

AB> and

>> An assignment to an indexed variable t[i] = val is
>> equivalent to settable_event(t,i,val).

AB> Both of these functions are

>> not defined or callable in Lua.  We use [them] here only
>> for explanatory purposes.

AB> Both gettable_event and settable_event use rawget to check
AB> the current value of the table, and rawget's description
AB> says:

>> index may be any value

AB> settable_event uses rawset to do the setting, and rawset's
AB> description says:

>> index [must be] any value different from nil

AB> See also <http://lua-users.org/lists/lua-l/2006-05/msg00378.html>.

-- 
Best regards,
 Dmitriy                            mailto:iassenev@gsc-game.kiev.ua