Starting Out Top LiteralsComments Contents

Comments

Comments should be used both sparingly and effectively in code. Scam allows for three kinds of comments for documentation:

file
all text in a file after the two character combination ;$ is ignored.
block
all text between the two character combinations ;{ and ;} is ignored.
line
all text on a line following the character ; is ignored.

A fourth comment is provided to pass instructions to the interpreter while parsing the source code. Such comments start with the combination ;@. Following the combination is an attribute-value pair. At the moment, only two directives are understood:

    ;@ file NEWFILENAME

This directive fools the parser into thinking it is parsing the file NEWFILENAME instead of the file that contains the directive. The other directive is:

    ;@ line NEWLINENUMBER

This directive fools the parser into thinking that the next line parsed in the source code file will have line number NEWLINENUMBER.

The file directive is useful for embedding Scam code in documents. If the document processor executes the embedded code (in the old file) by writing the code out to a new file and calling the Scam interpreter on that file, the processor can fool the interpreter into thinking it is parsing the old file. This is useful if the embedded code causes an error, as error messages will now reference the old file, not the new file. The document processor can also reset the line number to the line number at which the embedded code begins using the line directive.

lusth@cs.ua.edu


Starting Out Top LiteralsComments Contents