They say I write Ruby like Perl

K

Kero

I'd be interested to know *why* it is a language convention, and more
raise BrainDamagedException(Java)

We like UpperCamelCase, but don't like the lowerCamelCaseCompromise.

Part of it is just getting used to, but ...
I share this, and I think ruby capable editors could be told to gray out
underscores within variable and method names. (so that they are visible
but can be easily ignored while reading).

Gray out? No way. Have you ever printed var_with_underscore on a printer
that places your underscore lower than you want? Absolutely unreadable.

I think that the underscore is *not* a space and *not* a dot, but clearly,
visibly connects the words. Especially in Ruby where "method param" is
perfectly valid, but totally different from the equally valid
"method_param".

When I tried SciTe (I think it was scite) recently, some folding striked the
this-is-folded-line right through the underscores. That was an immediate
turn-off for me.

Bye,
Kero.

PS: old habits die hard. Accidentally, I came from Java to Ruby, too. Yes, I
frowned upon the underscores when I started (at the time, we had the printer
mentioned above at work; a2ps helps). Right now, I think it is 'just a
convention' and should be followed. For completeness, when I started with
Java, I frowned upon lowerCamelCase. I still do.
 
S

Steve Litt

i guess this thread comes to something like:

when in Ruby do as the Rubyists do, or don't if it bugs you.

Yes, and I'd like to thank everyone who gave me their ideas. Most of the ideas
I'll use instantly. A few I might not. I see parallel assignment as less
readable than individual assignment statements.

I really love all the shortcuts Ruby gives you to get things done. And I love
that the shortcuts don't harm encapsulation or other positive code qualities.

For awhile I was trying to get Node.pm to use two iterators with blocks
instead of the traditional callback routines (actually in addition -- I want
to keep all features in Node.pm and Node.py), but there's not a yield_a and
yield_b command, so I couldn't do it with both the entry and exit callbacks,
and having them each fire at the right time is vital.

Once again, thanks everyone -- it was like Ruby Boot Camp.

SteveT

Steve Litt
http://www.troubleshooters.com
(e-mail address removed)
 
G

gwtmp01

For awhile I was trying to get Node.pm to use two iterators with
blocks
instead of the traditional callback routines (actually in addition
-- I want
to keep all features in Node.pm and Node.py), but there's not a
yield_a and
yield_b command, so I couldn't do it with both the entry and exit
callbacks,
and having them each fire at the right time is vital.

Just capture the blocks into Proc objects and use Proc#call to invoke
the block:

def on_entry(&block)
@on_entry = block
end

def on_exit(&block)
@on_exit = block
end

def main
@on_entry && @on_entry.call( # entry args go here)
# do stuff
@on_exit && @on_exit.call( # exit args go here)
end

Maybe this will give you some ideas.


Gary Wright
 
E

Eivind Eklund

I'd be interested to know *why* it is a language convention, and more
important why it is a lanaguage convention that from this thread it
seems rubyists vigorously insist upon? For those of us who were
"raised" with a language like Java (or as some on this list may say,
brain damaged ;-), lowerCamelCase seems more pleasing to the eye than
identifiers_with_underscores.

I'll say why I tend to insist on it: Because more or less any
consistent convention makes it easier to work with code than having
code that is mixed between two or more different conventions. Ruby
has a convention that is followed a lot, including being in all the
standard libraries.

This means that your code can either be single convention - following
that convention - or it can be multi-convention, by adding your own
style in addition to the standard one. I consider single convention
to more or less always be better.

Eivind.
 
J

Jim McFarland

I'd be interested to know *why* it is a language convention, and more
important why it is a lanaguage convention that from this thread it
seems rubyists vigorously insist upon? For those of us who were
"raised" with a language like Java (or as some on this list may say,
brain damaged ;-), lowerCamelCase seems more pleasing to the eye than
identifiers_with_underscores.

I was "raised" on C and then went to Java and am now learning Ruby, so
underscores are I what I started with. In trying to conform to the
Ruby conventions, it is a welcome thing to go back to underscores
instead of camelCase, but that's just my own preference.

later...
jim
 

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

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top