Comments & Style
SeaTurtle comments are text within the source code of a SeaTurtle program that is not meant to be interpretted. It can literally be anything, but it is best reserved for explanatory words about a program. Anything that comes after a semicolon(;
) on a line in a SeaTurtle program will be interpretted as a comment. For example, the following program has three comments:
; A program to draw a line
SET length 100 ; How long the line should be
FORWARD length ; Actually draw the line
It is good style to use comments in any part of a program that is non-obvious. Comments will make your program easier to read by others that you share it with, but they will also make your program easier to read by you when you come back to it at a later date. There is really no downside to using comments. They are simply ignored by SeaTurtle when your program is run.
Here are some other style suggestions:
- Use intelligent and descriptive variable names
- Indent any code within a block (a block is anything that ends with
END
) - Use all capitals to write keywords built-in to SeaTurtle and lowercase or camelCase to write names of your variables and subroutines
- Whenever you find yourself repeating the same lines of code over again, consider whether a loop or subroutine could help. A general programming principle is DRY—Don't Repeat Yourself
Of course you don't need to follow any of these style conventions. They are just suggestions. Every programming language has its own style, and so does every programmer.