Documentation
GitHubTwitter
  • overview
    • What is Lua++?
    • Why Lua++?
  • language improvements
    • Compound Assignments
    • Postfix and Prefix Operators
    • The Continue Statement
    • Constant Variables
    • Type Annotations
      • Function Annotations
    • Classes
      • Constructors
      • Templating
      • Inheritance
      • Encapsulation
    • Events
    • Macros
      • Lenient
      • Comment
      • C-Arrays
  • contributing
    • Installing the Project
Powered by GitBook
On this page

Was this helpful?

  1. language improvements
  2. Macros

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).

PreviousLenientNextC-Arrays

Last updated 2 years ago

Was this helpful?