comments – Commenting code in Scheme

comments – Commenting code in Scheme

All three of the forms you mention are single-line comments. The double-semicolon may have originally arisen as a cue in Dorai Sitarams SLaTeX typesetting package that the comment was to be typeset as ordinary text, rather than as program text.

Scheme also has multi-line comments.

In particular, it appears that R6RS, like Racket, allows the use of #| and |# to begin and end multi-line comments. Also, the utterly magnificent #; combination comments out a full s-expression. So, for instance, if you write

#;(define (terrible-function a)
    (totally-broken-code
     here))

The entire definition is considered commented-out.

The comment character is ; and anything following that on the line will be ignored. The difference is visual. I have often seen a single ; used if the comment is on a line with code, ;; if the comment is on a line by itself, and ;;; if its a heading of some sort. The most important thing in commenting is likely to follow whatever conventions you see in the code youre working with.

comments – Commenting code in Scheme

MIT/GNU Scheme allows the use of ; for single-line comments and #| and |# respectively for opening and closing multiline comments. Just tested on version 10.1.10.

Leave a Reply

Your email address will not be published. Required fields are marked *