Indentation vs. "end"s

R

Ross Bamford

I think we can learn a lot from programming languages and Python.
First off, we should be writing in a fixed space font so we
can take visual cues from spacing more easily.
Next, why do we need periods at the end of a sentence
when we know that two spaces after a word mean
that the previous sentence just ended Doesn't
that make sense And do we really need caps at
the beginning of a sentence we know all sentences
are capitalized and we have just defined that
two spaces before a word means that it is at the
beginning of a sentence next we should look at
spelling double consonants don't realy add to
the meaning so begining now we spel words by
droping repeated consonants just look at al
these great benefits we can learn from python
self.we self.just self.need self.to self.learn
self.to self.ignore self.certain self.aspects
self.that self.may self.cary self.over

:))))))))))

"Programming languages and Python". Love it.
 
F

Fritz Heinrichmeyer

Rubyist said:
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.

if a text is accidentally reformatted (alt-q in emacs, it seems to me
ruby users are more often vim users, at least on this list) semantic is
destroyed, as in python. This is not the case with i.e. javascript or perl.

Maybe ruby as "javascript on steroids" would have even more success.
Blocks could be written with do

container.each do(i,j) { /* like |i,j| */ ..... }
 
J

James Edward Gray II

I think we can learn a lot from programming languages and Python.
First off, we should be writing in a fixed space font so we
can take visual cues from spacing more easily.
Next, why do we need periods at the end of a sentence
when we know that two spaces after a word mean
that the previous sentence just ended Doesn't
that make sense And do we really need caps at
the beginning of a sentence we know all sentences
are capitalized and we have just defined that
two spaces before a word means that it is at the
beginning of a sentence next we should look at
spelling double consonants don't realy add to
the meaning so begining now we spel words by
droping repeated consonants just look at al
these great benefits we can learn from python
self.we self.just self.need self.to self.learn
self.to self.ignore self.certain self.aspects
self.that self.may self.cary self.over

<dies laughing>

James Edward Gray II
 
L

Luke Duncalfe

Jim Freeze said:
I think we can learn a lot from programming languages and Python.
First off, we should be writing in a fixed space font so we
can take visual cues from spacing more easily.
Next, why do we need periods at the end of a sentence
when we know that two spaces after a word mean
that the previous sentence just ended Doesn't
that make sense And do we really need caps at
the beginning of a sentence we know all sentences
are capitalized and we have just defined that
two spaces before a word means that it is at the
beginning of a sentence next we should look at
spelling double consonants don't realy add to
the meaning so begining now we spel words by
droping repeated consonants just look at al
these great benefits we can learn from python
self.we self.just self.need self.to self.learn
self.to self.ignore self.certain self.aspects
self.that self.may self.cary self.over


Classic!

; )
 
L

Luke Duncalfe

Honestly, I prefer ENDs to indentation, I prefer curly braces to ENDs.
But how about something like this:
def foo
@var
}


Oooh. Now I found quite attractive. It's like a single bookend keeping
things upright between itself and the wall.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Indentation vs. "end"s"

|Not a bad idea in itself. In fact, I think that really old Ruby
|versions (prior to my learning it with 1.4) did something like
|that. When modifiers were introduced (x if y, x while y, etc.)
|parsing became difficult and they were dropped. I think that's
|the case.

Very old versions of Ruby, before Wed August 24 1994, according to the
ancient record of history.

matz.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Indentation vs. "end"s"

|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?

We are experimenting double semicolons as well as "end"s, so that you
can type

class Foo
def bar(a)
p a
;;
;;

instead of

class Foo
def bar(a)
p a
end
end

Or you can even type

class Foo
def bar(a)
p a;;;;

But I'm still not sure if it's good enough to be remained in 2.0.
No, don't worry, we are NOT going to remove "end"s from the language;
double semicolons are just alternative.

matz.
 
C

Cameron McBride

I'm out of my league, but...

We are experimenting double semicolons as well as "end"s, ...
But I'm still not sure if it's good enough to be remained in 2.0.
No, don't worry, we are NOT going to remove "end"s from the language;
double semicolons are just alternative.

why? quite seriously, and quite naively, I don't understand the benefit.

Maybe it's just me, but the

class Foo
def bar(a)
p a;;;;

looks really different from the (current) standard

class Foo
def bar(a)
p a
end
end

It sounds to me like it'll make reading ruby libraries / code a bit
more difficult since both can exist. Is it worth that price? Am I
missing something?

Cameron
 
S

Serdar Kýlýç

The semicolons, imho, aren't visible enough to the (my?) eye. I still
believe that the curly brace to END is a decent option as it already
is familiar to many others. In most other languages the semicolon
denotes an end to a statement which for newbies (such as myself) it
may get confusing.

Hi,

In message "Re: Indentation vs. "end"s"
 
Y

Yukihiro Matsumoto

Hi,

It sounds to me like it'll make reading ruby libraries / code a bit
more difficult since both can exist. Is it worth that price? Am I
missing something?

No. The purpose of this experiment is hearing other opinions. So
yours is quite worthwhile.

matz.
 
M

MenTaLguY

No. The purpose of this experiment is hearing other opinions. So
yours is quite worthwhile.

For what it's worth, I also strongly dislike it. It was one of my least
favorite features of OCaml's syntax.

But here, the biggest problem is that (relative to other block endings
in pretty much any language I can think of), it's much harder to
visually count ;;s if they are squashed together as in your example.

I think this is largely because there aren't any visual cues to the
boundary between tokens. The gap between two ;s within the same ;; and
the gap between two ;s in adjacent ;; aren't visually distinguishable.

-mental
 
J

James Edward Gray II

For what it's worth, I also strongly dislike it.

Amen brother.

I don't think Ruby ever needs to be ashamed of being Ruby.

James Edward Gray II
 
R

Rubyist

The semicolons, imho, aren't visible enough to the (my?) eye. I still
I agree. Although using semicolons sounded a good idea for me, when I
saw:

def foo()
blah blah
blah blah
if blah blah
;;;;

I haven't liked them. But curly braces may me quite better. Yes... I
think it's worth to try without totally removing the "end"s. Just an
optional implementation. I am already *very happy* with Ruby's many
optional solutions. One may use or not "then"s, one may write a single
line conditional without using "end"s etc.

def foo()
blah blah
if blah blah
blah blah }
}
 
R

Robert Klemme

Yukihiro said:
Hi,

In message "Re: Indentation vs. "end"s"


We are experimenting double semicolons as well as "end"s, so that you
can type

class Foo
def bar(a)
p a
;;
;;

instead of

class Foo
def bar(a)
p a
end
end

Or you can even type

class Foo
def bar(a)
p a;;;;

But I'm still not sure if it's good enough to be remained in 2.0.
No, don't worry, we are NOT going to remove "end"s from the language;
double semicolons are just alternative.

I opt against. Reasons:

- difficult to read especially with multiple "end"'s (as others have
pointed out already)

- I doesn't feel right (aesthetically) to end something started with a
word ("def", "begin" or "do") with punctuation

- It could break existing code in very rare circumstances, i.e. if
someone used ;;;;;;;;;;;;;; as a visual boundary.

Kind regards

robert
 
F

furufuru

Rubyist wrote:
[. . .]
I haven't liked them. But curly braces may me quite better.
I'd vote for curly braces, if it's possible at all. (Curly braces are
already used for blocks, so I'm not sure it's possible/feasible.)

In fact, "do", "then", "end", etc. make one-liners harder to read
and, as a result, make them less valuable. Compare,
for example,

if cond then meth this; func that end #(1)

with

if (cond) {meth this; func that} #(2)

The second is easier to grasp at a glance. Why?
Because "names" are written in words and grammatical
constructions are written in symbols (except for "if").
Code (1) is harder to read because everything is a word.

In any case, however, I'm quite happy with Ruby. This issue
is very minor at best. All I'm saying is, if possible, I prefer
the style of code (2).

Regards,
Ryo
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top