|
On Fri, Jan 19, 2018 at 5:23 AM, Elias Hogstvedt<eliashogstvedt@gmail.com> wrote:Yes it will break everything, so I don't really expect this to be implemented. Perhaps a new language?If you can imagine a new language or be okay with breaking changes, do you think these changes make sense?On Fri, Jan 19, 2018 at 1:01 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:2018-01-19 12:26 GMT+02:00 Elias Hogstvedt <eliashogstvedt@gmail.com>:
(a)
> Since all the table functions in Lua only work or make sense on tables that
> are treated as lists we simply rename _G.table to _G.list. The list object
> should __index to _G.list so it's possible to do “mylist:insert(2)”
(b)
> Now that we have no table library we can create one with functions that only
> made sense on tables instead.
> table.get/setmetatable, table.rawget/set, table.rawequal, table.next,
> table.rawlen, table.pairs ( ? )
(c)
> The length operator on tables would no longer work unless we set a metatable
> on the table with the length operator.
(d)
> _G.ipairs would no longer be needed and so using pairs on lists would ensure
> correct order while on tables it would not. We can also put _G.pairs in
> _G.list.pairs to allow the syntax "for i,v in mylist:pairs() do"
(e)
> The list object would be constructed with the syntax [a,b,c] instead of
> {a,b,c} and can contain any value. However list keys are strictly numbered
> and ordered.
(f)
> "mylist = table.tolist(tbl)" - for converting table to list if the table
> is valid.
> "mylist = []" - to create a dynamically sized list.
> "mylist = [1,2,3,4,nil,6]" - to create a list that is 6 in length.
(g)
> Var args become a list object. Because of this I think "..." should be
> replaced with @. Here are some lua examples with the old method on top.
> I believe this would simplify and make the language easier to understand.
Seven breaking changes. Not merely breaking some programs that have
worked unchanged since Lua 2.1, breaking all of them.
Whatever you call this new language of yours, please don't include the
letters L,U,A consecutively anywhere in its name.