[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Suggestion: syntax sugar for object methods inside table constructor
- From: Spar <developspartv@...>
- Date: Wed, 2 Jun 2021 17:30:24 +0300
This syntax doesn't introduce anything new in terms of keyword or different tokens order.
It's true, if would be more useful if it could help with function(self) methods.
The reason "you type key explicitly to make it obvious" seem to be not related here. Knowing that "function a()" adds function in "a" explicit enough, if you want more use regular syntax. We already have implicit keys without for array part, no one stops you from using  = val
On 2 Jun 2021, 17:25 +0300, Suote127 <email@example.com>, wrote:
In my opinion, this sugar should not be added.
The normal form of table constructors can clearly point out the fact that the functions are just normal values. This can help newcomers understand Lua's OOP better:OOP is just saving functions in a table and accessing them in the special ways that metatables provides.
Lua does not have a lot of features,it tries to solve problems with a little more code but not with more grammars.I think this is Lua's idea.This sugar is not so necessary, and adding it does not fit the idea.