Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Block Comment Syntax #1401

Closed
wants to merge 1 commit into from
Closed

Conversation

will
Copy link
Contributor

@will will commented Sep 7, 2015

puts "before"         # => before
#[
this is all a
puts "commented out"
comment
#]
puts "after"          # => after

pp 3 + #[ no #]5      # => 3 + 5 = 8

I looked through this comment comparison list for languages that used # for inline comments, to see if any of their block comments felt right to me.

I wanted something that still had the # char, so ruby ==begin ==end was out. Some were close, lisp #| BlockComment |#, and cobra /# BlockComment #/, and awk <# BlockComment #>.

However I think it's nice to have both "start block comment" and "end block comment" start with # so you can toggle sections quickly, by only editing one of the pair, so I came up with this.

@jhass
Copy link
Member

jhass commented Sep 7, 2015

I won't fight this but I never missed the defacto missing block comment from Ruby. Any sane editor should have a toggle comment shortcut and whether I hold shift while going down to the closing position of the block comment or not doesn't make that much of a difference. In fact [] is not the easiest thing to type on non-US keyboards, thus most will rely on their editor inserting it. And whether the editor inserts a bunch of # or just a #[/#] doesn't make a difference at all. Just my two cents.

@asterite
Copy link
Member

asterite commented Sep 7, 2015

I agree with @jhass . We didn't bother adding or thinking about block comments because we find it much easier and faster to just select a region of code and press "your shortcut for commenting code". Having to mark the beginning of the comment, and then the end of it is slower.

And then inevitably someone will want these comments to be able to nest, because if you comment a large piece of code that has these kind of comments, it won't work. It's not hard to do, but I never really felt the need for that.

I do, however, find that inserting a comment between expressions could be useful for quick debugging. But if that's the only use case, I wouldn't include this feature.

@0x1eef
Copy link

0x1eef commented Sep 7, 2015

I never use my editor to do that, but I don't mind typing # by myself a few times for multi-line comments. I'm not crazy about the syntax for this.

@will
Copy link
Contributor Author

will commented Sep 12, 2015

Wanted to give it a few days, but with no support I'm not going to push for this. I'll close it out to keep the pr list trimmed.

@will will closed this Sep 12, 2015
@Nakilon
Copy link
Contributor

Nakilon commented Sep 13, 2015

I would like the __END__.

@LevitatingBusinessMan
Copy link

LevitatingBusinessMan commented Jul 21, 2020

Honestly this should've just have gotten merged.

@asterite asterite mentioned this pull request Jul 22, 2020
@LevitatingBusinessMan
Copy link

@asterite, you can uncomment multiple lines via your IDE yes. But that's only if your IDE supports it, some terminal text editors don't.

More importantly, with line comments you will never be able to do this:

/*return*/ some_function()

Sometimes I temporarily comment out parts of lines. I might be the only one that does stuff like that though.
But it's certainly another reason as to why I like to have an extra syntax for commenting.

@straight-shoota
Copy link
Member

Most terminal text editors should support bulk comments. If yours doesn't, maybe you should look for one with more features? To me this sounds like a very basic feature for code editing, even when a language also has block comments.

Commenting parts of a line doesn't look like a strong use case. I'd never use that. Instead the individual expressions should be split into separate lines and then you can comment entire lines. That seems more reasonable than commenting out inner parts of a line.

Overall I don't see much of a benefit, actually, for having block comments. Instead, it comes with a number of disadvantages: IDEs and syntax highlighters would have to be adapted to support it. And people would have to learn the new syntax, even if most probably don't have much desire to use it. You're the first one asking for block comments since this PR was closed 5 years ago. So it doesn't seem there's a huge demand for that.

@HertzDevil
Copy link
Contributor

HertzDevil commented Jan 10, 2023

If you insist, this is what I discovered while investigating #11392:

#<loc:push>#<loc:"
  __             _
 / _| ___   ___ | |__   __ _ _ __
| |_ / _ \ / _ \| '_ \ / _` | '__|
|  _| (_) | (_) | |_) | (_| | |
|_|  \___/ \___/|_.__/ \__,_|_|
",1,1>#<loc:pop>
  
puts#<loc:push>#<loc:"
  this is a comment
",1,1>#<loc:pop> 1 #<loc:push>#<loc:"
  another comment
",1,1>#<loc:pop> + #<loc:push>#<loc:"
  !!!!
",1,1>#<loc:pop> 2 + #<loc:push>#<loc:" ?????????? ",1,1>#<loc:pop> 4 # => 7

(please don't actually do this)

@beta-ziliani
Copy link
Member

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants