On Sat, Jan 05, 2002 at 03:00:00PM +0900, Mark Hahn wrote:
> If the tail end (line going left) is all 'end' and '}' lines, then it could
> look like this:
> 
> 
> \
>  \
>   \
>    \
>     \
>      \
>       \
>       |
>       |
> 
> which is much shorter.  The reason is that if you hit the end of the file,
> or a def, module, or class keyword, all closing lines could be inserted by
> the compiler for you, instead of giving an error like it does now.

<facts>

end's in Ruby are not just noise.  Consider the following:

songs = data.collect {|song, author|
  case author
  when 'Frank Sinatra'
    author = 'Frankie'
  when 'Louis Armstrong'
    author = 'Satchmo'
  end

  "#{author.upcase} -- {song}"
}.compact.sort

(Same applies when replacing `{' and `}' with do and end.)  It
couldn't be done without end's, you'd have to follow it with a
`songs.compact!.sort!'.  (Not that bad, agreed.)

</facts>


<personal taste>

I find the end-less indentation hard to read, I can't seem to keep
track of what refers to what block in nests deep than three or four.

That is also why I don't understand the hype about enforced
indentation in Python---it makes things more difficult for me, but I
must be a strange case...

But if it is just visual appearence that one is after, ``hanging''
blocks could be done just like:

if success
  if found
    table.each {|row|
      row.each {|column|
        column.each {|item|
          puts item            }}} end; end

Cut off an `if', cut off an `end'; cut off an `each' (or any construct
with and `{' ), cut off a `}'.  Not as lazy as the interpreter
handling it for yourself, but you can still `}.sort', `end.collect'
and so on.

</personal taste>


Massimiliano