lua-users home
lua-l archive

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



On 11/24/23 20:22, bil til wrote:
Am Fr., 24. Nov. 2023 um 20:17 Uhr schrieb Claudio Grondi
<claudio.grondi@freenet.de>:
''' multiline string
                                  first level '''
This looks somehow funny, this really works well in Python?
In Python there are two options for multiline strings: """ some multiline string literal """   and   ''' some multiline string literal ''' .

As I am coming to Lua after more than 30 years of Python I appreciate the infinite depth of nesting Lua comes with.

This allows me even better styling with more options for different kinds of strings as the four Python comes with (1.'x' 2."x" 3.'''x''' 4."""x""").

I found in Lua also the equivalent of the "(magic switch)" I was using in Python to switch between two blocks of code by inserting/deleting only one character in source code text to make one or the  other block a comment.



... just wondering how they distinguish empty strings "" from this
start sign of a multiline string ...
This is easy ... they allow occurrences of unnamed string literals in code ... something Lua could probably also do with ease if decided to go this way. This would not brake anything adding a nice way of using string literals as comments.

This works because the first part of the triple quote is considered to be an empty string and because it is not necessary to give it a name it's OK for the parser which bumps into a single quotation starting a string literal scan.