lua-users home
lua-l archive

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


Perl has auto-vivification and it creates way more problems than it solves. Also agree this should not be part of the language and the error when trying to index a null value is a good thing.

On Sat, Feb 29, 2020, 02:12 Soni "They/Them" L. <fakedme@gmail.com> wrote:


On 2020-02-28 10:10 p.m., Soni "They/Them" L. wrote:
>
>
> On 2020-02-28 10:05 p.m., Egor Skriptunoff wrote:
>> On Sat, Feb 29, 2020 at 12:59 AM Anton Jordaan wrote:
>>
>>     If I want to access the value of t[a][b][c][d][e]
>>
>>     I suggest that it would be more useful -- and more consistent --
>>     if the
>>     "Attempt to index a nil value" error is deprecated and, instead, the
>>     indexing of undefined variables does the following:
>>
>>     When reading: simply return nil.
>>
>>
>>
>> http://lua-users.org/lists/lua-l/2017-02/msg00308.html
>> See solution #3
>>
>>
>>     When writing: automatically assign a single-entry table to each
>>     undefined variable, with the given index the sole entry.
>>
>>
>> Creating a table would better be explicit.
>
> mktable -p (table, a, b, c, d, e, f, g, ...).with = value
>
> (this is valid lua fwiw, but good luck making it work :v)

correction, this is valid lua:

(mktable -p (table, a, b, c, d, e, f, g, ...)).with = value

oh well .-.