utilizing ++ and -- for comments

P

Peña, Botp

Since ++ and -- wont see the light of day in ruby, can we use it for comment
notation?

define:
1. -- equal to # comment
2. --- (or more dashes) equal to =begin
next --- (or more) equal to =end
3. ++ same comment as #1 above
4. +++ same comment as #2 above

Reasons:
1. I like "--", very clean [1]
2. We can faq ++/-- questions as: "they are used for comments" :)

kind regards -botp

--
[1] Eg
cat a1.rb
-----------------------------------
Program Name: Sample_Programming.rb
Purpose: this a sample prg showing
- same as =begin and =end comments.
clean, don't you think so? imho
-----------------------------------

p "hello, world"

p "hello, ruby" -- this is just a sample


-- I know
p "hello, world, ruby."
 
G

George Moschovitis

I also think that the =begin, =end notation is not comfortable to use.
Maybe some other way of multiline comments should be added in Ruby 1.9
for example /* */ or %c{ }

-g.
 
D

Douglas Livingstone

for example /* */

That's a regex

I wouldn't mind the (* *) syntax though, and *() are all baside
eachother on my kbrd so nice and easy to type :)

Douglas
 
N

nobu.nokada

Hi,

At Sat, 12 Feb 2005 22:23:40 +0900,
Douglas Livingstone wrote in [ruby-talk:130595]:
That's a regex

A regex beginning with * is illegal, but

%/string/*2

is valid syntax.
I wouldn't mind the (* *) syntax though, and *() are all baside
eachother on my kbrd so nice and easy to type :)

Also,

p(*[1,2,3])
 
D

Dave Burt

+1

"Peña said:
Since ++ and -- wont see the light of day in ruby, can we use it for
comment
notation?

define:
1. -- equal to # comment
2. --- (or more dashes) equal to =begin
next --- (or more) equal to =end
3. ++ same comment as #1 above
4. +++ same comment as #2 above

Reasons:
1. I like "--", very clean [1]
2. We can faq ++/-- questions as: "they are used for comments" :)

kind regards -botp

--
[1] Eg
cat a1.rb
-----------------------------------
Program Name: Sample_Programming.rb
Purpose: this a sample prg showing
- same as =begin and =end comments.
clean, don't you think so? imho
-----------------------------------

p "hello, world"

p "hello, ruby" -- this is just a sample


-- I know
p "hello, world, ruby."
 
R

Robert Klemme

Christian Neukirchen said:
Why do you guys always propose comment syntaxes of icky languages? }:)

That's exactly the same question that I had in mind while reading this
thread...

robert
 
D

Douglas Livingstone

Why do you guys always propose comment syntaxes of icky languages? }:)

All I'm after are multi line comments - if you've got some non-icky
syntax I'm all for it :)

/* */

If it doesn't qualify as a regex, I'm all for it!

Douglas
 
B

Brian Mitchell

Since ++ and -- wont see the light of day in ruby, can we use it for comment
notation?

define:
1. -- equal to # comment
2. --- (or more dashes) equal to =begin
next --- (or more) equal to =end
3. ++ same comment as #1 above
4. +++ same comment as #2 above

I would like to see a multi-line that can nest other multi-line
comments. useful for quick and dirty code changes.

--- Disable this entire section
--- My other section that holds
important documentation.
---
code ... ...
---

so this is a problem. Lua has some interesting comments. They are ugly
but they have some nice uses. see http://www.lua.org/pil/1.3.html
(bottom half). Any ideas how we could clean it up a bit? I like the
single hyphen toggle.

Brian.
 
D

Dave Burt

Brian Mitchell said:
I would like to see a multi-line that can nest other multi-line
comments. useful for quick and dirty code changes.

--- Disable this entire section
--- My other section that holds
important documentation.

+++ Disable this section
--- My other section that holds
important documentation.
 
D

David A. Black

--927295978-1793839709-1108219602=:31957
Content-Type: MULTIPART/MIXED; BOUNDARY="927295978-1793839709-1108219602=:31957"

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

--927295978-1793839709-1108219602=:31957
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

Hi --

Since ++ and -- wont see the light of day in ruby, can we use it for comm= ent
notation?

They've already seen the light of day:

irb(main):001:0> ++ 100
=3D> 100
irb(main):002:0> -- 100
=3D> 100

And we have comment mechanisms already too :)
define:
1. -- equal to # comment
2. --- (or more dashes) equal to =3Dbegin
next --- (or more) equal to =3Dend
3. ++ same comment as #1 above
4. +++ same comment as #2 above

Reasons:
1. I like "--", very clean [1]

I understand that not everyone likes the hash-mark comment idiom. But
isn't this just another of the thousand things where it is literally
impossible for everyone to have it exactly how they want, and Matz has
gone ahead and made a reasonable decision? We can of course talk
about what looks best (and not agree), what's easiest to type (and not
agree), what will/won't make Perl/C/Java/etc. programmers feel at home
(and not agree about whether we care :), and so forth. But that will
be true no matter what the comment mechanism is.


David

--=20
David A. Black
(e-mail address removed)
--927295978-1793839709-1108219602=:31957--
--927295978-1793839709-1108219602=:31957--
 
S

Sam Roberts

Quoteing (e-mail address removed), on Sat, Feb 12, 2005 at 10:59:34PM +0900:
All I'm after are multi line comments - if you've got some non-icky

Why?

If you start a line with '#' doesn't your editor start the next line
with '#'? And doesn't it word wrap in comments?

Btw, /* ... */ isn't used as a "multi-line" comment in C very often, you
usually see

/* begin of
* a comment
* so
*/

Which isn't much different from the #

The only place its really useful is NON multi-line comments

def foobie(a, b, /* c, */ &proc)

Cheers,
Sam
 
N

Navindra Umanee

David A. Black said:
They've already seen the light of day:

irb(main):001:0> ++ 100
=> 100
irb(main):002:0> -- 100
=> 100

Interesting. What does that do? Integer identity op?

Cheers,
Navin.
 
G

George Moschovitis

Why do you guys always propose comment syntaxes of icky languages?
}:)

well, anything instead of =begin, =end!!

-g.
 
G

George Ogata

Brian Mitchell said:
I would like to see a multi-line that can nest other multi-line
comments. useful for quick and dirty code changes.

--- Disable this entire section
--- My other section that holds
important documentation.

Here's yer multiline comment:

g@crash:~/tmp$ cat test.rb
puts 1
%{
puts 2
%{
puts 3
}
puts 4
}
puts 5
g@crash:~/tmp$ ruby test.rb
1
5
so this is a problem. Lua has some interesting comments. They are ugly
but they have some nice uses. see http://www.lua.org/pil/1.3.html
(bottom half). Any ideas how we could clean it up a bit? I like the
single hyphen toggle.

And here's yer "single-hyphen" toggle:

g@crash:~/tmp$ cat test.rb
def q; yield end

puts 1
%q{
puts 2
%q{
puts 3
}
puts 4
}
puts 5
g@crash:~/tmp$ ruby test.rb
1
5
g@crash:~/tmp$ cat test.rb
def q; yield end

puts 1
q{
puts 2
%q{
puts 3
}
puts 4
}
puts 5
g@crash:~/tmp$ ruby test.rb
1
2
4
5



<grin>
 
D

David A. Black

Hi --

How about

<<-COMMENT
foozle
COMMENT

laptop:~$ ruby -w
<<E
blah
E
-:1: warning: useless use of a literal in void context


You could of course assign to something. It might start looking weird
though.

(I'm not suggesting prolonging the process of finding alternatives to
what we've got now, though.)


David
 
D

Douglas Livingstone

If you start a line with '#' doesn't your editor start the next line
with '#'? And doesn't it word wrap in comments?

Nope, I think I need to teach it how to behave properly :)
 
B

Bertram Scharpf

Hi,

Am Sonntag, 13. Feb 2005, 05:45:00 +0900 schrieb David A. Black:
Commenting out code in C is normally done with `#if 0',
`#endif' what isn't really shorter.
laptop:~$ ruby -w
-:1: warning: useless use of a literal in void context

Maybe you like the METAFONT way:

def gobble ( str = nil) end

gobble {
code_that_was_commented_out
syntax_highlighting_is_applied
}

gobble %{
Text that was commented out.
}

Bertram
 

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
474,167
Messages
2,570,911
Members
47,453
Latest member
MadelinePh

Latest Threads

Top