Squirrel Comments

From SigMod
Revision as of 03:46, 27 October 2023 by Mince (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BACK
HOME
NEXT

A comment is a human readable note which was inserted by a programmer to denote the what, how, or why behind code. Comments are ignored by the compiler and only serve to make the code easier to understand or use for programmers. Comments come in two flavors: single line and multi line comments. Single line comments go until they hit a new line character (\n). Multi line comments have a start and end token, anything between them is commented out.


To insert a single line comment, prefix it with // or #.

// I'm a comment that takes the whole line
local darth_variable = 404 # I'm an inline comment

To insert a multi line comment, use /* to start and */ to end.

/*I
      am
          a
      multi
  line
comment
*/
local foo = 2;

You can "nest" single line comments, but you can't do this with multi line comments

//////////////////////// okay
/* // okay */
/* /* not okay */ */

The compiler will end the multi line comment at the first end token (*/) it sees, so the second one is outside of any comments and results in a compile error.