News for hackers. Stuff that matters.
Re:Block Comments Are a Bad Idea by lozenge on Wednesday October 11, 2017 @07:59AM (#15448998)
Surely the solution is heredocs? You effectively define your own comment closing string at the comment opening point.
Re:Block Comments Are a Bad Idea by Athas on Wednesday October 11, 2017 @08:07AM (#15449051)
Yes, heredocs (or "here-comments", since you want them ignored, not just stored in a string variable) would likely be a solution for all but the most pedantic. The final recourse of the pedant would be to point out that no single closing string would be appropriate in all cases, and you are in principle required to read the code you want to comment out, in order to find a closing string that is not already contained within it.
Re:Block Comments Are a Bad Idea by cat199 on Wednesday October 11, 2017 @08:23AM (#15449139)
:.,+n|grep eofstr
Re:Block Comments Are a Bad Idea by okdana on Wednesday October 11, 2017 @08:29AM (#15449174)
I use heredocs for 'commenting out' code in shell scripts a lot. For example:

    : <<- 'NOOP'
    some
    code
    here
    NOOP
In some languages there is a very slight performance impact to doing this, however. Especially in the shell, because it actually has to juggle file descriptors whenever a heredoc or herestring is involved — even if you're directing it into a built-in like `:`. (It only costs a few-dozen microseconds though.)

Also, heredocs are irritating because they usually can't deal with indentation properly. bash and zsh support the `<<-` operator which allows you to indent the closing delimiter, but only if you use tabs. Most other languages require the delimiter to be the first thing on the line, which is tedious and confusing.

Python's triple-quotes seem to solve all of these problems, and they're one of the best things about Python's grammar IMO. I wish every language had that, combined with the ability to treat expressions as statements. It'd be a little ugly in C-like languages, but certainly usable:

    '''
    my comment
    ''';