lua-users home
lua-l archive

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


I fully agree. the ":" prefix or suffix also works if you dont like the "!"

I tend to keep "@" reserved only for use for annotations (that are additional optional markup embedded in the source code, but that can be compiled and run without taking them into account; annotations define a separate language with its own API, like in Java). Using annotations in a Lua-based API is something to be specified later, but it should already have a reserved syntax allowing them to be longer than a single keyword, with some parameter list).

Annotation are very productful for code generation (including automated replacement of code fragments), code analysis (when the Lua parser alone is not sufficient and what needs to be documented is a runtime behavior or some usage contraints for libraries), automated code documentation (comments in Lua are not enough, as they are in free form. However "@" is already used to embed annotations within Lua comments for the same purpose, but it's hard to use annotations in a Lua compiler to give non-imperative *hints* to the compiler, if it needs to also parse the content of comments, that the normal Lua parser has already dropped, this requires a hook inside the Lua parser when it parses the content of comments before dropping them, so that it can feed some external metadata storage in the abstract sytnax tree that is built by the normal parser)


Le dim. 24 mai 2020 à 21:19, pocomane <pocomane_7a@pocomane.com> a écrit :
On Sun, May 24, 2020 at 8:40 PM Andrea wrote:
> Local pi is const = 3.14
> Local handle will close = fopen()

The Xavier proposal works because it reuses an already existing
keywords. With "is" and "will" you will face the
backward-incompatibilities we already saw in another recent thread.

The sole way I see to solve the new-keyword issue "Generally", is to
extent its namespace with something that before was forbidden (but do
not change the identifier one). The <> syntax is a particular case of
this method, applied to a very specific context, but it can be made
very general. For example, we could allow ":" as a final character in
keywords. Then you can invent

local pi is: const = 3.14

or

local pi const: = 3.12

or

tab = {0}
delete: tab 0

or any other funny keyword, without the risk of incompatibility.
Obviously a prefix can be used instead

local pi :const = 3.14

ore more "Readable" simbol

local pi @const = 3.14