Will Java ever allow comments to nest?

Roger Riggs Roger.Riggs at oracle.com
Wed Jul 22 14:02:14 UTC 2020


Hi,

It looks a lot like the quotes within quotes problem that has existed in 
shells forever and
was addressed in text blocks with a different outer delimiter.

The kind of encoding below "*/" is error prone and makes the 
developer encode the real intent.
There's got to be a better way, even if it takes a new kind of doc 
comment delimiter for the outer.
It will be a bigger change for javac and javadoc but makes it possible 
to redefine/reinterpret the delimiters.
Maybe you can do something with:

    /***
         /**
          * ...
          */
    ***/



Regards, Roger

On 7/7/20 6:40 AM, Johannes Kuhn wrote:
> This is a source incompatible change.
>
> It would break /* inside comments:
>
>     /**
>      * Determines whether or not the tokenizer recognizes C-style 
> comments.
>      * If the flag argument is {@code true}, this stream tokenizer
>      * recognizes C-style comments. All text between successive
>      * occurrences of {@code /*} and <code>*/</code> are discarded.
>      * <p>
>      * If the flag argument is {@code false}, then C-style comments
>      * are not treated specially.
>      *
>      * @param   flag   {@code true} indicates to recognize and ignore
>      *                 C-style comments.
>      */
>
> That's the javadoc of StreamTokenizer.slashStarComments(boolean).
> With your proposed change, the javadoc comment would not be closed at 
> the end.
>
> - Johannes
>



More information about the discuss mailing list