[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Indentation vs. "end"s

Rubyist

1/29/2006 9:53:00 PM

Hi,

I *REALLY* love Ruby very much. But I always find those "end"s somewhat
ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
that Ruby use indentation (as Python does) instead of "end"s.

Today, I have seen a post in:

http://www.artima.com/weblogs/viewpost.jsp?thr...


As far as I know, Bruce Eckel is a competent programmer and when I saw
that he was agree with me, I surprised.

What do you think about those "end"s? Do you *REALLY* like them?
Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
will another solution be available?

72 Answers

luke

1/30/2006 1:02:00 AM

0


"Rubyist" <nuby.ruby.programmer@gmail.com> wrote in message
news:1138571607.569617.32920@z14g2000cwz.googlegroups.com...
> Hi,
>
> I *REALLY* love Ruby very much. But I always find those "end"s somewhat
> ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
> that Ruby use indentation (as Python does) instead of "end"s.
>
> Today, I have seen a post in:
>
> http://www.artima.com/weblogs/viewpost.jsp?thr...
>
>
> As far as I know, Bruce Eckel is a competent programmer and when I saw
> that he was agree with me, I surprised.
>
> What do you think about those "end"s? Do you *REALLY* like them?
> Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
> will another solution be available?
>


I've got to declare that I also like the idea of dropping the ends a la
Python, although if the effect of that is that your whitespace becomes
strict I'm not sure which way is better. I have looked at some of my and
other people's Ruby code and often been tempted to select those last 5
'ends' and hit the delete button. : )

Luke


Jeff Schwab

1/30/2006 3:40:00 AM

0

Rubyist wrote:
> Hi,
>
> I *REALLY* love Ruby very much. But I always find those "end"s somewhat
> ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
> that Ruby use indentation (as Python does) instead of "end"s.
>
> Today, I have seen a post in:
>
> http://www.artima.com/weblogs/viewpost.jsp?thr...
>
>
> As far as I know, Bruce Eckel is a competent programmer and when I saw
> that he was agree with me, I surprised.
>
> What do you think about those "end"s? Do you *REALLY* like them?
> Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
> will another solution be available?


I like having something to search for in my editor. Explicit
block-ending tokens also help when I am skimming code to review its
structure.

Doug H

1/30/2006 4:11:00 AM

0

Yes I really like the end statements, and they make it easier for
beginners. It's possible to support both indenting and end statements
(i.e. support one mode or the other), and you don't need python's
redundant and unnecessary colons. I implemented this myself in a
parser. I don't think it is appropriate for ruby, however.

What would be even better would be to allow optional labels after end
statements, such as "end class", "end def", so the parser can catch
more errors.
I've implemented this as well in a separate project.

ptkwt

1/30/2006 4:46:00 AM

0

In article <nUfDf.49093$Kp.5722@southeast.rr.com>,
Jeffrey Schwab <jeff@schwabcenter.com> wrote:
>Rubyist wrote:
>> Hi,
>>
>> I *REALLY* love Ruby very much. But I always find those "end"s somewhat
>> ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
>> that Ruby use indentation (as Python does) instead of "end"s.
>>
>> Today, I have seen a post in:
>>
>> http://www.artima.com/weblogs/viewpost.jsp?thr...
>>
>>
>> As far as I know, Bruce Eckel is a competent programmer and when I saw
>> that he was agree with me, I surprised.
>>
>> What do you think about those "end"s? Do you *REALLY* like them?
>> Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
>> will another solution be available?
>
>
>I like having something to search for in my editor. Explicit
>block-ending tokens also help when I am skimming code to review its
>structure.

And having 'end' sure makes things like ERB easier (possible) to implement.


Phil

Rubyist

1/30/2006 6:48:00 AM

0

>> I have looked at some of my and other people's Ruby code and
>> often been tempted to select those last 5
>> 'ends' and hit the delete button. : )

Thank God! I am not alone on the earth! ;-D
Man, you've made me so laughed! Hahaha!

Rubyist

1/30/2006 6:57:00 AM

0

>> What would be even better would be to allow optional labels after end
>> statements, such as "end class", "end def", so the parser can catch
>> more errors.

That sound like a good idea. But what about "if", "when", "for",
"until" etc?
Hmm...
"endif", "end when", "end for", "end until", "end class", "enddef",...
Umh! A never "ended" nightmare.

Tim Hammerquist

1/30/2006 7:20:00 AM

0


Rubyist <nuby.ruby.programmer@gmail.com> wrote:
> <doug00@gmail.com> wrote:
> > What would be even better would be to allow optional labels
> > after end statements, such as "end class", "end def", so the
> > parser can catch more errors.
>
> That sound like a good idea. But what about "if", "when",
> "for", "until" etc?
> Hmm...
> "endif", "end when", "end for", "end until", "end class", "enddef",...

Or how 'bout "if - fi" and "until - done" and "for - done"...
nah. As much as the Bourne shell has a few constructs that
seem to meet your criteria, I don't think it's the answer.

I have to say, as much as I like the idea of significant
whitespace for *certain* things (preservation of vertical
space; force new programmers to indent), I just don't think it's
the right solution here, either.

Besides, Python has no solution for *which* scope is ended when
code is reverse indented. It's clean, but not descriptive.

I agree that Ruby's explicit "end"s make it nicer for use in
erb. And at least this way you can, for your posterity's sake,
do:

stuff.each do |thing|
if thing.instance_of?(other_thing)
thing.action()
end # if
end # each stuff

Cheers,
Tim Hammerquist

ngw

1/30/2006 11:46:00 AM

0

-Rubyist <nuby.ruby.programmer@gmail.com>:
> What do you think about those "end"s? Do you *REALLY* like them?
> Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
> will another solution be available?

You're asking for trouble when using something like eruby.

ngw

Dirk Meijer

2/1/2006 10:22:00 PM

0

i like the "end"s, it reminds me of the old days when i programmed my Texas
Instruments calculator and always forgot an "end" somewhere :P

2006/2/1, Phil Tomson <ptkwt@aracnet.com>:
>
> In article <nUfDf.49093$Kp.5722@southeast.rr.com>,
> Jeffrey Schwab <jeff@schwabcenter.com> wrote:
> >Rubyist wrote:
> >> Hi,
> >>
> >> I *REALLY* love Ruby very much. But I always find those "end"s somewhat
> >> ugly ( thousands of excuses to Matz ). I sometimes feel myself wishing
> >> that Ruby use indentation (as Python does) instead of "end"s.
> >>
> >> Today, I have seen a post in:
> >>
> >> http://www.artima.com/weblogs/viewpost.jsp?thr...
> >>
> >>
> >> As far as I know, Bruce Eckel is a competent programmer and when I saw
> >> that he was agree with me, I surprised.
> >>
> >> What do you think about those "end"s? Do you *REALLY* like them?
> >> Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
> >> will another solution be available?
> >
> >
> >I like having something to search for in my editor. Explicit
> >block-ending tokens also help when I am skimming code to review its
> >structure.
>
> And having 'end' sure makes things like ERB easier (possible) to
> implement.
>
>
> Phil
>
>

Eric Hodel

2/1/2006 10:22:00 PM

0

On Feb 1, 2006, at 1:37 PM, Luke Duncalfe wrote:

> "Rubyist" <nuby.ruby.programmer@gmail.com> wrote in message
> news:1138571607.569617.32920@z14g2000cwz.googlegroups.com...
>> What do you think about those "end"s? Do you *REALLY* like them?
>> Will Ruby-2 offer an alternative? Well, maybe not "indentation" but
>> will another solution be available?
>
> I've got to declare that I also like the idea of dropping the ends
> a la
> Python, although if the effect of that is that your whitespace becomes
> strict I'm not sure which way is better. I have looked at some of
> my and
> other people's Ruby code and often been tempted to select those last 5
> 'ends' and hit the delete button. : )

I typically find I'm doing something wrong if I have five ends in a
row. Too much complexity in one method. Three is usually my max,
but I don't make a rule of it, it just happens.

--
Eric Hodel - drbrain@segment7.net - http://se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...