I created this solution:
; use like this:
; (/* content ... */ <default-return>)
; or
; (/* content ... */) => #f
(define-syntax /*
(syntax-rules (*/)
((/* body ... */) #f)
((/* body ... */ r) r)))
But is it really the best or easiest way?
MIT, Gnu, R6RS and R7RS support multi-line comments like this:
You can't do it this way -- it won't work for a number of contexts. Here are some examples that won't work:
There is no standard multi-line comment in the Scheme reports up to R5RS, but R6RS has added a syntax that was widely used anyway:
#|...|#
.But if you really want to...
Here's what I was talking about in the comment: if you're willing to wrap the whole code in a macro, then the macro can process the whole body, which can be effective in many more contexts. Pretty much all of them except for trying to comment out syntactically invalid stuffs like the semicolon example above, or an unterminated string. You can judge for yourself whether it's really worth the effort...
(Personally, as much as I enjoy such games, I still think they're pointless. But if you really enjoy these games and you think they're useful, then see the homework section below...)
And an example:
Homework
For extra credit, extend it so you can comment out unbalanced parens. For example, make this work:
Obviously, the input as a whole should have balanced parens -- this means that there's not much point in implementing this kind of an extension. Even without it, what's the point in commenting out an unbalanced paren?
But if anyone got all the way here, then you must enjoy this kind of self-torture ... right?