lua-users home
lua-l archive

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


I always thought lua approach on arrays was quite clever. I miss the fact that "non-arrays" cannot be counted with #, but beside that, all is fine.

2017-06-25 5:42 GMT-03:00 Dibyendu Majumdar <mobile@majumdar.org.uk>:
Hi Roberto,

On 25 June 2017 at 08:03, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> I was looking to see if Lua ever had a distinct array type, and
>> reading the hopl paper it seems that Lua 1.1 indeed had distinct array
>> and table types but the two types were merged to a single table type
>> in Lua 2.1.
>
> That is not true. Lua 1.1 had distinct notations for constructors of
> arrays (lists) and records, but the underling table was already the same:
>

Ah, okay. I misunderstood following to mean that there were distinct types:

   The form ‘@[]’ was used to create arrays, as in ‘@[2,4,9,16,25]’.
   In such tables, the keys were implicit natural numbers starting at 1.
   The form ‘@{}’ was used to create records, as in ‘@{name="John",
   age=35}’. Such tables were sets of keyvalue pairs in which the
   keys were explicit strings.

Thanks for the correction.

Regards
Dibyendu




--
"A arrogância é a arma dos fracos."

===========================
Me. Italo Moreira Campelo Maia
Co-fundador do Grupo de Usuários Python do Ceará
Secretário ForHacker (fb.com/ForHackerSpace)
Desenvolvedor Full-Stack, Escritor, Empresário, Visionário
-----------------------------------------------------
Meu Livro, Site, Blog
===========================