For the complete documentation index, see llms.txt. This page is also available as Markdown.

Comment

As mentioned in the postfix section, traditional Lua comments prevent the implementation of the decrementation operator (--). To disable the traditional single-line Lua comment, one can use --!comment. Once the compiler sees that this macro is specified, single-line comments will transition over to the # sign and the -- operator will replace --- for decrementation.

Below is a code segment that would yield an error at compilation after applying the --!comment macro.

--!comment

-- this is an invalid comment (and code)
local v = 1
print(v---)

The following code segment demonstrates the correct usage of the --!comment macro and the syntax change it produces.

--!comment

# Valid new comment
local v = 1
print(v--)

An alternative to this approach of managing the conflicting comment and decrement operator issue would be to use reassignments (var = var - 1) or compound assignments (var -= 1).

Last updated