lua-users home
lua-l archive

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


On 14 March 2018 at 14:09, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> > t[i]=undef is a special syntax form that means "remove the key 'i'
>> > from table 't'".
>>
>> But it seems like an assignment.  Wouldn't be better to create a special
>> syntax for removing a key from a table instead pretending it as an
>> assingment?
>>
>> You should have considered a pair of functions, such as table.undefine(t,
>> i) to undefine a key, and table.defined(t, i) to check whether the table
>> has the key.  Why did you choose the assignment?
>
> Mainly because of compatibility with older versions. As I said, I like
> the idea of using 't[i]=undef' even in older versions, as a idiom to
> better document things being removed from a table.
>
> We fully agree that it may be confusing; that is why we are testing it
> in this work release.
>
> A new syntax (such as "delete a[k]" or anything like that) would be
> the worst for compatibility, as new programs using it would not even
> compile in older Lua. Functions are not that bad; with something
> like
>
>       table.undefine = table.undefine or function(t,k) t[k] = nil end
>
> we get compatibility in older Lua. But with 't[i=undef' we have
> compatibility without any work :-)
>

Above seems like a strange definition of compatibility. What would be
nice  is if users could deploy Lua 5.4 without having to change their
existing Lua or C code - that to me is backwards compatibility.
However I noticed that some of the apis have changed in incompatible
ways (e.g. GC interface). Also it is disappointing that compatibility
features for 5.1 and 5.2 are being dropped. Looks like we are going to
get another fragment in the Lua ecosystem :-(

Regards
Dibyendu