Comments

Memory is short—by writing we preserve It

As programs grow, it becomes harder to remember what each part does and why it was written that way. A comment is a note left in the code for humans to read. CSP ignores comments completely, so they never change what a program does.

Writing a Comment

A comment begins with two forward slashes (//). Everything after the slashes on that line is part of the comment.

Comment (noun)
A section of code for humans only that the language ignores
csp
You may also type <- !=>= <= for auto complete.

Only the second line runs here. The first line is skipped entirely.

A comment can also share a line with code. CSP runs the code, then ignores everything after the //.

csp
You may also type <- !=>= <= for auto complete.

To write a comment that spans multiple lines, start each line with its own //.

csp
You may also type <- !=>= <= for auto complete.

Slashes inside a string are just text, not a comment. DISPLAY("a // b") displays a // b.

Using Comments Well

Good comments explain why the code does something, not just what it does. The code already says what it does. Compare these two comments.

csp
You may also type <- !=>= <= for auto complete.

The first comment only repeats the code. The second tells the reader something new.

Comments are also useful for temporarily disabling a line of code without deleting it. This is called commenting out code.

csp
You may also type <- !=>= <= for auto complete.

Remove the // and the line runs again.

Comments in Other Languages

Not all languages use \\ to denote comments. See below for some various comment types.

python
You may also type <- !=>= <= for auto complete.

java
You may also type <- !=>= <= for auto complete.

fortran
You may also type <- !=>= <= for auto complete.


Next: Conditionals