From: Rick DeNatale Date: 2007-05-23T01:59:45+09:00 Subject: Re: How to adopt "Python Style" indentation for Ruby On 5/22/07, M. Edward (Ed) Borasky wrote: > But I want a *blue* bike shed next to *my* nuclear power plant. > > Anyhow, here's a couple of examples of things pretty much "standard > Ruby" that I still find confusing coming from other descendants of Algol > 60 syntax: > > 1. attribute_accessor :person > > self.person = "Ed" > > I really want it to be "attribute_accessor person" I assume you meant attr_accessor which is a method which takes one or more symbols or strings and generates methods with names based on those strings which reference instance variable names based on those strings. attr_accessor person would use the VALUE of the variable person as the name, and since person would likely not be defined yet, that value would be nil. > -- the constant > mixing of the same name with and without a preceding colon in Ruby is as > confusing to me as Perl's "$hash{'key'}" referring to an entry in > "%hash" vs. another variable entirely called "$hash". I won't comment on perl's use of sigils in this regard. > 2. Both curly braces and begin / end pairs to define scope, with one > variant having a higher binding priority than the other. The fact that I > don't even remember which one it is that has the higher binding priority > is an added factor in my dislike. I think there's some misunderstanding here. Curly braces are used to denote a proc, begin/end delimits a sequence of expressions which are executed in sequence and whose value is the last expression executed. Begin blocks are usually used with internal rescue clauses for exception handling. The pickaxe classifies begin/end as an operator with low precedence thus a * fred + begin puts "Hi mom" 5 end is evaluated as (a * fred ) + (begin puts "Hi mom" 5 end) {} and do/end aren't operators, but in almost all cases delimit procs and so the question of their relative priority is moot as far as I can tell since you can't have two procs next to each other in ruby source. As for the 'binding priority' of {} vs. begin/end, I'm not sure I can think of a legal situation in which the sequence {...} begin... could even occur in ruby code with no line break before the begin. But I could be wrong. > There are some others, but those are the two biggies. I'm slowly getting > used to semicolons as separators and open syntactic forms forcing a > continuation, but even those irritated me at first when I started > learning R after spending a number of years with Perl. When learning a language, I think that it's best to work with these irritations until the logic of why they are there starts to reveal itself with experience. Fighting it just inhibits learning how to think in the new language. I wouldn't expect that English should be changed so that the order natural of his nouns and his adjectives in her sentences would be reversed; or that the articles before all of his nouns should be required; or that the genders should be assigned to all his nouns, or that the pronouns possesive should agree in the gender with the possession instead of the possessor; to make her more natural to speakers native French. Language design involves a careful balancing of several factors. I think that both Matz and Guido did admirable jobs in designing and evolving Ruby and Python respectively, each with a different set of principles. Even Shakespeare stuck to the English rules when he wrote in English, and the French rules when he wrote in French. unless he was trying for comic effect as when Katharine's lady-in-waiting, Alice was teaching her English in Henry V. Personally, I'd prefer to let Ruby be Ruby, and Python be Python, or as the French say: Vive la difference! -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/