Thanks for the reply!

You're right that code rewritten like your example would lead to a 
syntax error, but this unusual case is easily avoided.

My intention is to make the code more readable on the printed page, 
simple word processor or anywhere other than a dedicated Ruby 
development environment.

It's obviously a matter of taste, but I  think the eye can use visual 
clues to "parse" the code into it's nested parts. You can tell at a 
glance which "class", "def", "if","elsif","else" , etc etc goes with 
which "end", which block ( of contiguous code, not necessarily a "Ruby" 
block )of code is nested in what other block, and where, that every 
block is paired with one "end", and that there are no extra 
"ends"s,"else"s etc etc. This leaves at least a little more brain power 
to process the meaning of each easily picked out block, and how it 
relates to its containing blocks.

Without these lines, the code on the page might be cleaner, but the code 
in your brain is messier, because it's often ( actually almost always ) 
difficult to tell the above things.

As far as mixing tabs and spaces, this is of course already a problem. 
But all that's needed is for the code writer to use the same combination 
of spaces and tabs up and down between each "vertical line". To make 
anything work, common sense must be used, and reasonable conventions 
must be adopted.

The only case where existing code would be broken would be in the rare 
case such as you gave above. It would be trivial to write a program 
which would automatically alter any code slightly to append any line 
beginning with a vertical line to the previous line, admittedly a pain, 
but there are always pros and cons to every suggestion which need to be 
weighed and it needs to be decided which outweighs which. I think the 
insights into the code gained visually at a glance outweigh these 
inconveniences.

That's my opinion anyway.

Thanks again for responding!


Jari Williamsson wrote:
> Alan Eden wrote:
>> |       |      @names.each do |name|      
>> |       |      |  puts "Hello #{name}!"    
>> |       |      end  
> 
> Rewriting like this would then result in a syntax error, following your
> suggestion:
> @names.each do
>     |name| puts "Hello #{name}!"
> end
> 
> And what if tabs and whitespaces are mixed in the code and different tab
> settings are used on different machines? This produces hard-to-read code
> even today, and your suggestion would make the code unreadable.
> 
>> I copied this example from Ruby in twenty minutes, page 4. Look at the
>> original and look at the above. Isn't it much clearer? 
> 
> No, I think it clutters the code, I want Ruby code to be clean.
> 
>> Or is there a
>> good reason why this isn't done that I'm missing?
> 
> Apart from breaking existing code and editors, this doesn't add anything
> to the Ruby language. It's in the same league as syntax highlighting. If
> you need good formatting, use text a source code formatter or (more
> fun!) build one yourself.
> 
> 
> Best regards,
> 
> Jari Williamsson

-- 
Posted via http://www.ruby-forum.com/.