lua-users home
lua-l archive

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



On Aug 5, 2014 10:26 AM, "Coroutines" <coroutines@gmail.com> wrote:

> Er... following up on a trailing thought: I think I'd also want a
> __construct metamethod for Lua's types and a way to define object
> literal syntax.

The reuse of definition of syntax depends on "#include" or "import *", which in turn breaks the rule that every chunk is compiled independently.

> { 'cat', 'dog', 'mouse' } would chain to table.__construct('cat',
> 'dog', 'mouse')

What does { cat={} } do?

Do you want table.__construct to be global? What happens when we fight over it?

If it's lexical, does it really make much difference to write

    do
      local __tconstruct = your_constructor;
      a = {'cat', 'dog', 'mouse'}
    end

vs

    do
      local t = your_constructor;
      a = t{'cat', 'dog', 'mouse'}
    end

?

Admittedly I get sick of writing v{1,2} + v{3,4} sometimes, but when I really get sick of it I'm halfway to writing a mini-language anyway.

Jay