lua-users home
lua-l archive

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


On Mon, 11 Jan 2021 at 10:25, Italo Maia <italo.maia@gmail.com> wrote:
>
> > Perhaps there could be a command line flag to enable that behaviour.
> But it would probably create incompatibilities with existing code.
>
> As a ravi program is not compatible with lua, so that could go as a nice ravi only feature.

Making unqualified variables local by default is problematic because
then you need a way to declare globals like Python has.
A  better solution is probably to just issue warnings.

>
> Regarding arrays ...
> If ravi arrays are not that close to tables, why not give them their own syntax? Declaring arrays like tables when they don't behave the same in multiple levels might make code harder to read and write.
>

Ravi arrays appear as regular tables in Lua code. Also adding new
syntax for arrays is not that easy.

> I guess that 'number' is more consistent with existing Lua terminology.
> Is the number type in ravi just like the number type in lua (int or float)?
>

It is - I guess I stuck to the terms 'number' and 'integer' based on
the C typedefs in Lua (lua_Number, lua_Integer).


> Regarding nil ...
> So, that definition is so that the "set nil to remove element" feature for tables would work, I presume. To me, that is one of the Lua bits that can create confusion and make programs harder to understand. See the example:
>
> > x = {3,4,5}
> > #x
> 3
> > x[2] = nil
> > #x
> 3
> > for k, v in pairs(x) do print(k, v) end
> 1 3
> 3 5
>
> With ravi arrays, I assume the last line would be something like this:
>
> > for k, v in pairs(x) do print(k, v) end
> 1 3
> 2 nil
> 3 5
>
> Correct? Or setting nil would break things because nil is not of the type integer?

No, because a ravi array is integer[] or double[] - neither allow nils.

>
> Is there an official ravi docker image?
>

There was but I need to check if docker has deleted it. There is a
Dockerfile included so you can build an image easily.


Regards