Ruby multiline comments and Coffee

Hey,

I have to say I love almost everything about Ruby, but one thing I
always hated is the multiline comments. Would it be possible to seek
some inspiration from Coffeescript’s approach here, for a future version
of Ruby?
The current syntax doesn’t seem to fit into the language and it’s also
really annyoing that it has to be aligned to the start of the line.
I don’t see any major problems when implementing ### as a multiline
comment, but perhaps I missed something.

For anyone not familiar with coffee, this is how the multiline comments
look like there:

this is a multiline comment

PS: There is a problem that this would be potentially
backwards-incompatible, in case someone used ### lalala comment as a
single line comment.

well you can do

=begin
this
is
a
comment
=end

Also perhaps your editor / ide supports commenting blocks. Textmate sure
does

  1. I am aware of the current syntax of multiline comments. Like I said
    in my original post, I think the current syntax for multiline comments
    (=begin and =end) is one of the worst syntaxes I’ve ever seen in any
    language. This is why I am proposing to consider something like Coffee’s
    ###.

  2. Mentioning IDE features as an argument is a void argument. I can have
    an IDE that translates code to binary format, does this mean that
    programming languages where you have to write code in binary have a good
    syntax? In this case we can remove the parser from Ruby and just write
    code directly in Ruby bytecode. We can write an IDE that supports it
    then it’s fine right? Everyone just use that IDE and problem solved, we
    don’t need bloated Ruby interpreter with code parser.

In part, I see your point with inverting the existing blocks, but I
don’t think it’s that big of a deal, I work with coffee a lot and I
don’t really have problems with it, although my text editor colors it
nicely. I don’t really know anyone who doesn’t use some form of syntax
highlighting for Ruby development, so I’m not too worried about that. If
you’re writing a multiline comment you’re probably going to open and
close it in one go so it’s not that easy to make the mistake you’re
talking about. Somewhat more valid concern is if someone wanted to make
a single-line comment like #########################… I guess there
could be an extra character besides the #. Perhaps ##[ … ]## wouldn’t
be too terrible.

I don’t think the LUA syntax for the comments fits into the Ruby
language. ### still feels by far the best. But even --[[ is better than
=begin that must start at the beginning of the line.

=begin/=end are from pod (perl ‘plain old documentation’) markers,
intended
for the big explanatory documentation block at the top of the file.
Real
perl pod is itself a rich language, with tools for extracting it and
creating man pages and all that.

Neither perl nor ruby have what you’d call ‘true block comments’. At
this
point it would probably be hard to introduce a good syntax that doesn’t
conflict with someone’s existing comment style, but I wouldn’t mind
seeing
the discussion.

Personally I require my block comment markers to have distinct begin and
end tokens. I don’t care about nesting, I’m always happy to work within
the
spec for things like:

// /*
/* 0 */ 1
// */ 2

On 25 April 2013 14:48, Jan B. [email protected] wrote:

  1. I am aware of the current syntax of multiline comments. Like I said
    in my original post, I think the current syntax for multiline comments
    (=begin and =end) is one of the worst syntaxes I’ve ever seen in any
    language. This is why I am proposing to consider something like Coffee’s
    ###.

You haven’t seen Xquery comments then :slight_smile:

If you really wanted a better block comment then something like Lua’s
comments would work

–[[
this is a block comment
–]]

and this

–[[
this is a block comment
–[=[
this is a nested comment
–]=]
this is part of the outer comment
–]]

  1. Mentioning IDE features as an argument is a void argument. I can have

an IDE that translates code to binary format, does this mean that
programming languages where you have to write code in binary have a good
syntax?

The fact that the ide can make a minor niggle such as block comments
completely irrelevant is not to be over looked

The problem that I can see with the ### style of block comment is that
inserting ### somewhere in the file will invert all the existing blocks
and
the only way of telling that this has happened is if your
ide graciously colours your code in such a way to tell you about this
little slip. Again the ide comes to the rescue :slight_smile:

If you want to write binary you should do it like a real man …

$ cat > a.out

Thanks for that bit about perl, didn’t know that. It makes things make a
bit more sense.

I hope we can get some discussion going about this, it really would be
nice to have true block comments in ruby that are consistent with the
overall syntax.

Am 25.04.2013 12:41, schrieb Jan B.:

I have to say I love almost everything about Ruby, but one thing I
always hated is the multiline comments. Would it be possible to seek
some inspiration from Coffeescript’s approach here, for a future version
of Ruby?

I actually like the more or less lack of “real” multiline comments.

Using single line comments for example makes it easier to
distinguish comment lines from code lines when looking at output
from `grep’ searches, or to exclude them from a search more easily.

And my editor makes it easy to toggle lines into comments.