lua-users home
lua-l archive

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


2017-07-15 14:01 GMT+02:00 Dibyendu Majumdar <mobile@majumdar.org.uk>:
> On 13 July 2017 at 12:07, Javier Guerra Giraldez <javier@guerrag.com> wrote:
>> On 13 July 2017 at 10:44, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
>>> I am not sure what has propelled Python to this spot - perhaps the
>>> adoption by Google several years ago.
>>
>>
>> I think part of the merit is in NumPY library.
>
> So I have been trying to understand if there is something about Python
> that apart from the availability of NumPY makes it more attractive to
> numeric users than Lua.
>
> I asked a few weeks ago what Lua users thought about having a distinct
> array type (http://lua-users.org/lists/lua-l/2017-06/msg00299.html)
> but responses indicated no one thought this was important.
>
> However, as I learn Python, I am finding a few things pretty useful
> for certain types of programming needs.
>
> 1) First the existence of arrays - an array is fundamentally different
> from a Lua table as it has certain guarantees. In particular it is an
> ordered set, with no holes, and has efficient indexing and length
> operations. Lua tables cannot efficiently provide these guarantees (I
> am not including LuaJIT into consideration here).

I don't miss arrays at all. Lua does a good job. What I do miss are
tuples, i.e. constant arrays (not the same as Lua tuples).

In Lua, x[{1,2,3}] is legal, but not equal to another x[{1,2,3}.
In Python, x[[1,2,3]] is illegal, but x[(1,2,3)] is legal and
equal to another x[{1,2,3}].