Skip to content

Instantly share code, notes, and snippets.

@focusaurus
Created July 23, 2012 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save focusaurus/3165384 to your computer and use it in GitHub Desktop.
Save focusaurus/3165384 to your computer and use it in GitHub Desktop.
Syntax for comments/docs vs. disabling code blocks
So the question was: should programming languages use a different syntax (or character) for comments intended to be read by developer vs comments whose purpose is to disable code. For example, in my mind, these two scenarios are semantically entirely different intents:
# Add 2 px to account for border
width += 2
vs ......
#def someFunc():
# pass
The interpreter does the same thing in either case: ignore the line. However, I think it would be cleaner if there were 2 different syntaxes. For example:
#doc<<EOF
Here are some docs about this module. Maybe some parsers will read this and output HTML or whatever.
EOF
#template<<EOF
This is maybe an template using {{templateLang}} and we'll generate {{outputLang}} later
EOF
These feel very different to me as compared to wanting to hide a block of code from the interpreter/compiler. I guess in Java this is `/*` vs `/**`, which feels like a good distinction, although I don't like how visually similar they are. Ruby has some tricks like this too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment