lua-users home
lua-l archive

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


On Tue, Jul 16, 2019 at 8:43 AM Sergey Kovalev <kovserg33@gmail.com> wrote:
> There is no way to extend this attributes only hard coded const and toclose
..
> There is no annotation system. There are two hard coded cases.

Ok, maybe "Annotation system" is not a good name since it can not be
extended. However, it is not just an "Hard coded case". It is a new
syntax that could be used in several part of the language. Only two
cases are handled, just for now. On the list already appeared two
interesting proposal (at least for me):

<static> to handle first time initialization
<error-on-free-name> to protect a block of code from identifier typos
(to be honest, it was proposed to me, and it needs to add annotations
also to do/end block)

> You can not write "local <const> a,b"

With the last commits, you can write, for example:

local <const> a, b = 1, 2

> I prefer to use runtime constants:
...
> > But with the last commits we got constant propagation, so I really want <const>. And if we already have annotatations probably <toclose> is worth too.
> What does it mean exactly?

Constant propagation is exactly what makes compile time constants
better than runtime ones. As Roberto said [1]:

> Local constant variables initialized with compile-time constants are optimized away from the code.

(I did not look at code, however I performed some test, and it seems
to me that constant upvalues are optimized away too).

pocomane

[1] https://github.com/lua/lua/commit/f6aab3ec1f111cd8d968bdcb7ca800e93b819d24