Why dosn't ruby support // to comment?

i think use keyboard type "//" is fast than "#" to comment one line code.
  
:slight_smile:

···

_______________________________________________
programming is my life
my blog:http://blog.itpub.net/liubin
http://www.ruby-cn.org/

Because // is an empty regular expression.

Alex

i think use keyboard type "//" is fast than "#" to comment one line
code.

Alex already answered.
Furthermore Bin Liu, typing '#' is faster than '//' on my UK keyboard: it
requires only one key to be pressed rather than two. In different keyboard
layouts this may not be the case, but honestly I don't see the problem.

Cheers,
Antonio

···

--
My programming blog: http://antoniocangiano.com

Hi,

At Tue, 11 Jan 2005 15:38:21 +0900,
bin liu wrote in [ruby-talk:125995]:

i think use keyboard type "//" is fast than "#" to comment one line code.

And also, # is necessary for shebang line.

···

--
Nobu Nakada

bin liu wrote:

i think use keyboard type "//" is fast than "#" to comment one line
code.

What is faster depends on the keyboard layout. With a german keyboard
layout '#' is a single key, while '/' requires pressing two keys
simultanously. With a dutch keyboard layout (essentially NL) it is the
other way round.

If you want something that is fast and easy on almost any keyboard you
use '--'.

Josef 'Jupp' Schugt

···

--
Where on the ringworld does that 'Lord of the Rings' guy live?

This is pretty pedantic, but maybe comments should be really difficult to type. Something like "#JjI1e9()**" Then it won't be much more work to just extract out a smaller method, and use the new method name to document your code. :wink:

···

On Jan 11, 2005, at 1:38 AM, bin liu wrote:

i think use keyboard type "//" is fast than "#" to comment one line code.

:slight_smile:

_______________________________________________
programming is my life
my blog:http://blog.itpub.net/liubin
http://www.ruby-cn.org/

Francis Hwang

Antonio Cangiano wrote:

i think use keyboard type "//" is fast than "#" to comment one line
code.

Alex already answered.
Furthermore Bin Liu, typing '#' is faster than '//' on my UK keyboard: it
requires only one key to be pressed rather than two. In different keyboard
layouts this may not be the case, but honestly I don't see the problem.

On a German keyboard: Shift+7 Shift+7 to get '//' but only
one keystroke to get a '#'.

···

--
Stefan

Really? Must see UK keyboard then.
Didn't know that?!

Archit

···

On Tue, 2005-01-11 at 19:37 +0900, Antonio Cangiano wrote:

Alex already answered.
Furthermore Bin Liu, typing '#' is faster than '//' on my UK keyboard: it
requires only one key to be pressed rather than two.

Josef 'Jupp' Schugt <jupp@gmx.de> writes:

bin liu wrote:

i think use keyboard type "//" is fast than "#" to comment one line
code.

What is faster depends on the keyboard layout. With a german keyboard
layout '#' is a single key, while '/' requires pressing two keys
simultanously. With a dutch keyboard layout (essentially NL) it is the
other way round.

If you want something that is fast and easy on almost any keyboard you
use '--'.

Too bad it has the icky taste of SQL. :slight_smile:

···

Josef 'Jupp' Schugt
--
Where on the ringworld does that 'Lord of the Rings' guy live?

--
Christian Neukirchen <chneukirchen@gmail.com> http://kronavita.de/chris/

Not only that, but also a division by a regular expression.

That might sound silly, but in the pike programming language, you can split
strings with the / operator. Thus, someone might want to do this in ruby:

  class String; alias_method :/, :split; end;
  w1, w2 = "foo:bar"//:/; puts w2;

And to carry it even further, one can consider these examples too:

A division of a character constant:

  puts ?//5;

Or a division of a symbol:

  class Symbol; def /(x); x.send(self, 2); end; end;
  puts ://5;

But of course these last two cases could still be exceptions from the
comment syntax, just like # now is not a comment in single quotes either.

(But note that the // comment could be normal syntax in C too before it was
accepted by C99, for example this expression

  9//*foo*/2

has different meaning in traditional C and C99.)

ambrus

···

On Tue, Jan 11, 2005 at 04:11:31PM +0900, Alexey Verkhovsky wrote:

Because // is an empty regular expression.

Francis Hwang wrote:

This is pretty pedantic, but maybe comments should be really difficult
to type. Something like "#JjI1e9()**" Then it won't be much more work
to just extract out a smaller method, and use the new method name to
document your code. :wink:

Actually I'm surprised that this thread has generated so much interest. In
an effort to improve my Ruby skills, I've been reading the sources to some
well-known Ruby applications and libraries to see how good Ruby programmers
write code. (I won't name them but you-know-who-you-are.) One thing that
stands out is a noticeable lack of anything resembling a comment.

Just reading these sources you'd think that # already is as hard to type as
#Jjl1e9()**. :slight_smile:

Really? Must see UK keyboard then.
Didn't know that?!

After a quick google:

http://rjbs.manxome.org/images/2002/exile/matts/keyboard.jpg

It is just to the left of the enter key. My # is above my three, which
is easy to hit - shift on the right hand, 3 on the left.

Douglas

But, that's also a comment in Haskell :wink:

Ed

···

On Thu, 13 Jan 2005 22:38:03 +0900, Christian Neukirchen <chneukirchen@gmail.com> wrote:

Josef 'Jupp' Schugt <jupp@gmx.de> writes:
> If you want something that is fast and easy on almost any keyboard you
> use '--'.

Too bad it has the icky taste of SQL. :slight_smile:

--
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw

Zsban Ambrus wrote:

(But note that the // comment could be normal syntax in C too before it was
accepted by C99, for example this expression

  9//*foo*/2

has different meaning in traditional C and C99.)

What does it do?

Tim Hunter wrote:

One thing that
stands out is a noticeable lack of anything resembling a comment.

One school of thought is that a good code should be written in such a way that the need for internal comments is drastically reduced (small methods with limited responsibility, a lot of attention to names, and a detailed explanation with uisage examples in the beginning of a class).

I'd say, Ruby code of most popular programs is a great pleasure to read, even when comments are absent.
RDoc for some of these things (even many in the standard library) is a different story though :slight_smile:

Alex

Edgardo Hames <ehames@gmail.com> writes:

Josef 'Jupp' Schugt <jupp@gmx.de> writes:
> If you want something that is fast and easy on almost any keyboard you
> use '--'.

Too bad it has the icky taste of SQL. :slight_smile:

But, that's also a comment in Haskell :wink:

Now you just made me wonder if I ever saw commented Haskell source. :stuck_out_tongue:
(Not that it would be bad if I didn't...)

Bah, simply do literate Haskell. :wink:

···

On Thu, 13 Jan 2005 22:38:03 +0900, Christian Neukirchen > <chneukirchen@gmail.com> wrote:

Ed

--
Christian Neukirchen <chneukirchen@gmail.com> http://kronavita.de/chris/

Edgardo Hames wrote:

···

On Thu, 13 Jan 2005 22:38:03 +0900, Christian Neukirchen > <chneukirchen@gmail.com> wrote:

Josef 'Jupp' Schugt <jupp@gmx.de> writes:

If you want something that is fast and easy on almost any keyboard you
use '--'.

Too bad it has the icky taste of SQL. :slight_smile:

But, that's also a comment in Haskell :wink:

That is also the comment in AppleScript.

Zach

Florian Gross wrote:

Zsban Ambrus wrote:

(But note that the // comment could be normal syntax in C too before it was
accepted by C99, for example this expression

    9//*foo*/2

has different meaning in traditional C and C99.)

What does it do?

Even when using modern gcc, if you specify option "--traditional", this expression will be compiled without errors as "9/2". Without this option, gcc interprets "//" as the beginning of a line comment with all consequences.

Gennady.

Alexey Verkhovsky wrote:

Tim Hunter wrote:

One thing that
stands out is a noticeable lack of anything resembling a comment.

One school of thought is that a good code should be written in such a
way that the need for internal comments is drastically reduced (small
methods with limited responsibility, a lot of attention to names, and a
detailed explanation with uisage examples in the beginning of a class).

Yeah, I've read the reasoning behind that practice. I guess I'm just
old-school. The funny thing about the "good code should not _need_
comments" argument is that it just happens to justify what programmers have
always done, or actually not done, that is, not comment their code.

But, hey, now I'm sounding like a dour old pedant. Good Ruby code is a
pleasure to read, especially when I run across an idiom so clear and
powerful that it makes me want to start coding just so I can copy it.

And one of the things I learned at the feet of the masters is to not rely on
comments as a substitute for bad names and bad factoring.

I'd say, Ruby code of most popular programs is a great pleasure to read,
even when comments are absent.
RDoc for some of these things (even many in the standard library) is a
different story though :slight_smile:

100% agree.

Zach Dennis schrieb:

Edgardo Hames wrote:

Josef 'Jupp' Schugt <jupp@gmx.de> writes:

If you want something that is fast and easy on almost any keyboard you
use '--'.

Too bad it has the icky taste of SQL. :slight_smile:

But, that's also a comment in Haskell :wink:

That is also the comment in AppleScript.

Zach

Why don't make it userdefined:
$COMMENT_BEGIN="/*"
$COMMENT_END="*/"
$COMMENT_LINE="--"
:wink:
I don't think you'll ever satisfy the calls for a new comment syntax.

Peter

···

On Thu, 13 Jan 2005 22:38:03 +0900, Christian Neukirchen >> <chneukirchen@gmail.com> wrote: