why dosn't ruby support // to comment?

A

Antonio Cangiano

--_0111-1140-26-PART-BREAK
Content-Type: text/plain
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
 
N

nobu.nokada

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.
 
S

Stefan Lang

Antonio said:
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 '#'.
 
A

Archit Baweja

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.

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

Archit
 
J

Josef 'Jupp' Schugt

bin said:
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
 
P

Peter Schrammel

Zach said:
That is also the comment in AppleScript.

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

Peter
 
T

trans. (T. Onoma)

| $COMMENT_BEGIN="/*"
| $COMMENT_END="*/"
| $COMMENT_LINE="--"
| ;)
| I don't think you'll ever satisfy the calls for a new comment syntax.

Watch me...

$COMMENT_WRAP = { "^=begin" => "^=end", "/*" => "*/" }
$COMMENT_LINE = [ "#", "--", "//" ]

;)

Okay, maybe not _everybody_.

trans.
 
Z

Zsban Ambrus

Because // is an empty regular expression.

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
 
F

Florian Gross

Zsban said:
(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?
 
G

Gennady Bystritksy

Florian said:
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.
 
G

gabriele renzi

Tim Heaney ha scritto:
At Fri, 14 Jan 2005 07:49:10 +0900,
Zach Dennis wrote in [ruby-talk:126354]:
If you want something that is fast and easy on almost any keyboard you
use '--'.

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

But, that's also a comment in Haskell ;)

That is also the comment in AppleScript.

IIRC, also in Ada.


Also in Lua.

and, it seem to me, also in eiffel
 
D

Daniel Berger

gabriele said:
Tim Heaney ha scritto:
At Fri, 14 Jan 2005 07:49:10 +0900,
Zach Dennis wrote in [ruby-talk:126354]:

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

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

But, that's also a comment in Haskell ;)

That is also the comment in AppleScript.

IIRC, also in Ada.


Also in Lua.

and, it seem to me, also in eiffel

Hitler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top