lua-users home
lua-l archive

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




On Mon, Nov 27, 2023 at 1:08 PM Philippe Verdy <verdyp@gmail.com> wrote:
String literals used anywhere as comment ?

Forger that idea. Lua already has currification, and the ambiguïté caused by optional semicolons between statements.

We should be able to place comment anywhere (including in the middle of any lexical token, and in the middle of long literals with a proper syntaxe of these literals allowing them to be segmented and automatically concatenated by the parser if they are splitted into multiple tokens (to break too long lines, or insert comments or o
processing directives, we should allow thèse delimted tokens to be separaetd by any whitespaces or even none, without needing any additional operator tokens).

Note that long literals are NOT just for strings. These literals may be preprocessed for other types or could as well have some preprocessing directives or indicators, allowing several syntaxes, like those used in XML/HTML, or MIME, or hexadecimal, base64, or other bases, giving freedom for developpers to wrote thdor constants thd way they wish.

Then comments are just a other type of literals, excdot that it uses a directive or indicator, instructing the lexer to discarc the token and not pass it to the parser.


That would be a great addition if you want to run an obfuscated Lua contest. I don't think splitting identifiers and composite operators using comments is conducive to readable code. The old language Algol 68 allowed whitespace in identifiers, which looked better than using underscores or camel case, but it required that all the keywords were either in upper case or tagged in another way (some computers did not support lower and upper case in the '60s):

'begin
  'int my counter := 0;
  'while my counter < 10 'do
    my counter +:= 1
  'od;
  print(("my counter = ", my counter, newline))
'end


Ge'