none
Why not use single line comment format for block comments too? RRS feed

  • Question

  • This is a bit general, but why do other languages feel the need to include multiple ways to express comments?

    Visual Basic.NET uses single-line comments to express comments on multiple lines too, simply by splitting it up.

    ' I am a multi-line comment
    ' expressed using multiple
    ' apostrophes, rather than
    ' a special "block" comment. 
    
    ' I am also an end-of-line comment.

    Are there any disadvantages to this? There must be because Object Pascal/Delphi, for whatever reason, feels the need to use more than 3 kinds of comments, depending on the compiler.

    Thanks for any explanation.

    Sunday, January 14, 2018 3:55 PM

Answers

  • Yea why do Chinese and Japanese persons prefer chopsticks and why do European people prefer to eat with a fork and a knife and American people with a fork and Thai with a spoon while Indian and Arabian prefer with their right hand. 

    Do you have a real answer, I don't. 

    Oh and in VB we can also use three quotes for so called xml documentation. 

    ''' <summary> ''' In this way we can create documention. ''' Depending on the kind of class it can be very exstended ''' </summary> Module Module1 Sub Main() End Sub

    End Module



    Success Cor

    • Marked as answer by Lucy Qu Sunday, January 14, 2018 4:49 PM
    Sunday, January 14, 2018 4:06 PM
  • This is a bit general, but why do other languages feel the need to include multiple ways to express comments?

    Visual Basic.NET uses single-line comments to express comments on multiple lines too, simply by splitting it up.

    ' I am a multi-line comment
    ' expressed using multiple
    ' apostrophes, rather than
    ' a special "block" comment. 
    
    ' I am also an end-of-line comment.

    Are there any disadvantages to this? There must be because Object Pascal/Delphi, for whatever reason, feels the need to use more than 3 kinds of comments, depending on the compiler.

    Thanks for any explanation.

    No - during compilation, they're stripped out anyway.

    *****

    I set up a routine a while back that allows a developer to write multi-line comments (for VB Net) that will conform to a maximum character length per line.

    I can find it if you're interested.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Lucy Qu Sunday, January 14, 2018 4:49 PM
    Sunday, January 14, 2018 4:16 PM

All replies

  • Yea why do Chinese and Japanese persons prefer chopsticks and why do European people prefer to eat with a fork and a knife and American people with a fork and Thai with a spoon while Indian and Arabian prefer with their right hand. 

    Do you have a real answer, I don't. 

    Oh and in VB we can also use three quotes for so called xml documentation. 

    ''' <summary> ''' In this way we can create documention. ''' Depending on the kind of class it can be very exstended ''' </summary> Module Module1 Sub Main() End Sub

    End Module



    Success Cor

    • Marked as answer by Lucy Qu Sunday, January 14, 2018 4:49 PM
    Sunday, January 14, 2018 4:06 PM
  • This is a bit general, but why do other languages feel the need to include multiple ways to express comments?

    Visual Basic.NET uses single-line comments to express comments on multiple lines too, simply by splitting it up.

    ' I am a multi-line comment
    ' expressed using multiple
    ' apostrophes, rather than
    ' a special "block" comment. 
    
    ' I am also an end-of-line comment.

    Are there any disadvantages to this? There must be because Object Pascal/Delphi, for whatever reason, feels the need to use more than 3 kinds of comments, depending on the compiler.

    Thanks for any explanation.

    No - during compilation, they're stripped out anyway.

    *****

    I set up a routine a while back that allows a developer to write multi-line comments (for VB Net) that will conform to a maximum character length per line.

    I can find it if you're interested.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Marked as answer by Lucy Qu Sunday, January 14, 2018 4:49 PM
    Sunday, January 14, 2018 4:16 PM
  • I can find it if you're interested.


    No thank you Frank, but thank you.

    @Everyone, I didn't expect that it might be as simple as "just because". Thank you for your help. :)

    • Edited by Lucy Qu Sunday, January 14, 2018 4:49 PM
    Sunday, January 14, 2018 4:48 PM
  • No thank you Frank, but thank you.

    Less than 24 hours -- not too bad. ;-)

    *****

    Lucy,

    Maybe you or someone else can use this so I took the idea from what I had originally and I put it all together in a small program that I then zipped up and uploaded here:

    (Link Removed)

    The program is pretty simple; it will take the input text that you enter (and/or paste in) and it will then generate multi-lines of comment text with each line conforming to a maximum number of characters. When you first turn it on, this is what you’ll see:

    As with most of the programs that I write (not many), if you hover your mouse over the labels, you’ll see some “quick help” on the topic:

    There’s a spell checker built into it (U.S. English only). I can certainly use it and maybe you and others here will find it helpful also.

    It works similarly to what you’re used to but as you can see there, you have the option to have it check the spelling as you type or to only check it on demand using the context menu.

    What you’ll see is very straightforward and needs no further instruction.

    The textbox that’s on top (or Dev’s version of one) is editable but the one that shows the resultant comment text at the bottom is read-only. Still though, you can copy/paste the way that you’re used to doing.

    You might want to have a look at the Microsoft document about this:

    https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/comments-in-code

    Using the ‘long’ comment from that page:

    ' This comment is too long to fit on a single line, so we break 
    ' it into two lines. Some comments might need three or more lines.


    I’ll copy it and paste it into the upper text area:

    Once you have text in the upper text box, you might want to experiment with the maximum characters per line then click the button to see the result:

    Since the lower text area is read-only, you can’t clear it but if you remove all text from the upper text area, I have it set up to remove everything from the lower one also:

    Experiment some with that, including the Boolean to retain the input line breaks. I’ll show you what I mean using the following prose:

    In my original, I had a button to copy the resultant comments to the clipboard. I don’t have that now but if you want, I can put one there. You can freely select all and copy from the lower text area though.

     

    I hope you find it helpful. :)

    ***** EDIT *****

    I found and corrected an error. This version has a button to copy to the clipboard now:


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Monday, January 15, 2018 6:42 PM