Can I comment out code blocks that contain comments?

Tell me I have a code like this

some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code

      

and I would like to comment on the whole block like this

/*
    some_line_of_code
    some_line_of_code
    /* some comment about code */
    some_line_of_code
    some_line_of_code
*/

      

As you can see, even the SO code analyzer will not look at the last 2 lines of code comments. Can I comment out code blocks that contain comments?

edit: To clarify, I need this to be able to comment out large sections of code to check if a modified function can compile in a package that might not otherwise be compiled until all the changes are done.

+8


source to share


5 answers


In SQL Developer, I highlight all PL / SQL lines that I want to comment out and use Ctrl+ /.



Obviously, you would like to quickly comment and uncomment a few lines. This will put --

in front of each line you select. Do the same command to uncomment.

+13


source


As @Acroneos said, there is no way. This is common behavior in most programming languages. Comments as well as toheres are recognized by lexers. And lexers work with context-free grammars. that is, lex can usually only recognize expressed expressions.

You can still use the C / C ++ ( #if 0

/ #endif

) approach . See Conditional Compilation . But it doesn't look "so nice".



begin
 something1;
 $if false $then
  something2;
 $endif;
endl;

      

+3


source


you can use -

so this code:

some_line_of_code some_line_of_code -- some comment about code some_line_of_code some_line_of_code

will be:

--some_line_of_code --some_line_of_code ---- some comment about code --some_line_of_code --some_line_of_code

+1


source


No, because everything between the first delimiter until the next last delimiter will be recognized as a comment (= not handled by the compiler). This is how multiline comments work: if the first delimiter (/ *) is recognized, the compiler will ignore everything until the very next delimiter (* /) is recognized. Now that you know this, you should understand why your second / * will never be recognized by the compiler as a comment delimiter.

However, you can mark comments with special characters or concatenations in the multi-line comment sector to output comments to different sections.

0


source


Shortcut to comment line: Command + Option + / (on Mac)

0


source







All Articles