Created
May 9, 2012 11:20
-
-
Save francescom/2643833 to your computer and use it in GitHub Desktop.
Playing with C style comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playing with C style comments and nested comments (you can AND and OR comments) | |
// (c) F. Munafò - Call them Munafò's comments? :) | |
// I kow this in not good practice. Yes, yes. It is just for fun. | |
//////////////// A Sample //////////////// | |
/* put a SPACE (after *) to switch to MODE 2 =>*/ | |
alert("Mode 1"); | |
/*/ | |
alert("Mode 2"); | |
/*/ | |
// put a SPACE (after *) FOR SWITCHING TO MODE 2.2 (if in mode 2) => /*/ | |
// this is executed only switch 1 is off OR switch 2 is on | |
alert("Mode 1 or mode 2.1"); | |
/*/ | |
// this is executed only if both switches are on (both spaces inserted) | |
alert("Mode 2.2 only"); | |
//*/ | |
//////////////// The Fundamental Elements //////////////// | |
// : : : The Switch - opens a "switchable" comment : : : // | |
// Off: | |
/**/ | |
// On: | |
/** / | |
// May have comments: | |
/* add space after * to comment=> */ | |
// : : : The Inverter - inverts the comment status : : : // | |
// (if put inside a comment, the following text is not commented and vice versa) | |
/*/ | |
// If the comment is open it works like */ otherwise it works like /* | |
// : : : The Closer - closes a comment if open (and gives no error otherwise) : : : // | |
//*/ | |
// If the comment is open it works like */ otherwise it is just ignored | |
//////////////// Advanced Elements //////////////// | |
// : : : Secondary inverted switch - OMG! : : : // | |
// Off: (the // is part of it) | |
// /*/ | |
// On: (the // is part of it) | |
// /* / | |
// May have comments inserted: | |
// add space after * to uncomment=> /*/ | |
// This is a bit complicated | |
// If no comment is open, it does nothing (subsequent code is executed) | |
// If a comment is open, it behaves like an inverted switch: | |
// If OFF it behaves like */ closing it | |
// If ON it does nothing leaving the comment open | |
// It can be coupled with an inverter to obtain a | |
// : : : Secondary straight switch - OMG! : : : // | |
// subsequent code is executed only if it is ON AND comment was open already | |
// thus ANDING comment states | |
// Off: (the // is part of it) | |
// /*/ | |
/*/ | |
// On: (the // is part of it) | |
// /* / | |
/*/ | |
// May have comments inserted: | |
// add space after * to comment=> /*/ | |
/*/ | |
//////////////// Another Sample //////////////// | |
/* put a SPACE (after *) to switch to LOCAL =>*/ | |
alert("Remote"); | |
/*/ | |
alert("Local"); | |
/*/ | |
// put a SPACE (after *) FOR SWITCHING LOCAL TO DISK 2 => /*/ | |
alert("Remote or disk 1"); | |
/*/ | |
// this is executed only if both switches are on (both spaces inserted) | |
alert("Local disk 2"); | |
//*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment