lua-users home
lua-l archive

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


On second thought, ":" (as a prefix) is fine for extension keywords in Lua syntax, and it looks like we can also have "::" for namespaces (needed for reusing/imprting libraries without unexpected clashes on their identifiers, provided that we can also reisolate their identifiers in a local namespace, or selectively rename them with a specific instruction like
  :using mw = :require('Mediawiki');

Here I use the ":" prefix twice for two extension keywords in order to define a namespace "mw" with the new ":using" statement type, and an explicit use of the builtin pseudo-function/operator ":require", then I can call:
  x=mw::parse('{{Int:Lang');

So these are also valid:
  x:const = 1;
  file:toclose = open('filename');

and preferable to the ugly (not general enough and creating parsing difficulties with shift-reduce ambiguities solved very arbitrarily like in C++ and Java) extension mechanism reusing < and >:
  x<const> = 1;
  file<toclose> = open('filename');

which would not work with:
  <using> mw = :require('Mediawiki');

and which would still not support namespaces.


Le dim. 24 mai 2020 à 21:30, Andrea <andrea.l.vitali@gmail.com> a écrit :
On a second thought, Yes you are right, “is const” and “will close” would look too much Basic or COBOL-ish ;)

Up to now, “const!” and “close!” look the best to me, but I do not know if they are easily doable 

Maybe there must be an opening symbol to make the job easier for the parser?

In the end, I am fine with <close> and <const> They are getting the job done - I just need to get used to them 

   Andrea 



--
Andrea Vitali