Indentation vs. "end"s

J

joesb

joesb said:
Instead of voting for multiple "end xxx", I would like to suggest that
more pairs/keyword than "do ... end" and "{ .. }" can be used to define
a block.

For examples:

begin ... end
is ... end
then ... end

Because sometimes, the correct word is not "do". For examples to define
mapping I'd like to do

Brain.learn :cooking is
...
end

rather having "do" there.
It also simplify many semantic in Ruby for example. defining
class/method could be viewed as a method that takes a block. But "do"
wouldn't make sense there, but:

class Person is #<<< just a method taking a block
def say(message) is #<<< Don't know :S
...
end
end

It may make Ruby code reflect more closely to what I am thinking in
word.

To extends it further, may be a syntax for a method to specify what
word they want to use instead of "do". It must be possible to still use
"{}" or "do/end", just that another word can also be used instead.

For example of where "do" isn't the right word (at least for me), look
at Markably and Ezra's Where Plugin.
 
H

Hal Fulton

joesb said:
It also simplify many semantic in Ruby for example. defining
class/method could be viewed as a method that takes a block. But "do"
wouldn't make sense there, but:

class Person is #<<< just a method taking a block
def say(message) is #<<< Don't know :S
...
end
end

It may make Ruby code reflect more closely to what I am thinking in
word.

I think I like this. If it were an RCR, I just might vote for it.

But I would want two things:
1. Not too much proliferation, please. "is" and "do" are enough.
2. Let's make it clear that "is/end" and "do/end" shall behave
exactly the same way. No subtle differences, please.

This almost makes me want an alias_keyword... but that would probably
cause more problems than it would solve.


Hal
 
C

chiaro scuro

------=_Part_30068_19513680.1139239256323
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline


I definitely wouldn't want that. I really feel that "less is more".
Less keywords, not more, will result in less confusion.
I would love the is|do aliasing. Expressive code should be a primary
concern.
It also seems to be in line with the philosophy of the ruby libraries, the
if/unless constructs, etc..

-- Chiaroscuro --
Liquid Development Blog:
http://feeds.feedburner.com/blogspot/liquiddevelopment

------=_Part_30068_19513680.1139239256323--
 
L

Lionel Thiry

Mark Volkmann a écrit :
I'm not a fan of the curly braces, but if we do end up using them, I
hope we don't allow this.

def some_method(args)
# some code
}

If we're going to use them, I think they need to be matched, so a {
should appear at the end of the method argument list.

def some_method = ->(args) {
# some code
}

:p
 
G

Gregory Seidman

} >
} >>* On Feb 3 13:07, MenTaLguY ([email protected]) wrote:
} >>
} >>>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.
} >>
} >>I was going to write my own post, but it seems MenTaLguY did it for me!
} >>
} >>I am in total agreement; semicolons are an ugly way to end sections.
} >>Curly braces I have a much easier time with.
} >
} >
} > I'm not a fan of the curly braces, but if we do end up using them, I
} > hope we don't allow this.
} >
} > def some_method(args)
} > # some code
} > }
} >
} > If we're going to use them, I think they need to be matched, so a {
} > should appear at the end of the method argument list.
}
} def some_method = ->(args) {
} # some code
} }
}
} :p

You appear to be joking, but I'd kind of like that. I'd love to be able to
enclose *all* my scopes in curly braces and never type do/is/end at all.
I'm sure this comes of a C-syntax-centric worldview, but I'd love it.

module Foo {

def bar() {
#...
if (something) {
} elif (something_else) {
} else {
}
}

#...

}

class Baz {
include Foo
#...
}

} Lionel Thiry
--Greg
 
P

Peter Hickman

The only word of caution that I would wish to express here is:

NOT EVERYONE HAS ENGLISH AS A FIRST LANGUAGE!!!!!

It may be expressive in English but for some people it is just an arbitrary
sequence of symbols.

Bring back APL, that's what I say :)
 
A

Austin Ziegler

Austin Ziegler ha scritto:
I hope that the mistake that Python makes isn't repeated in Ruby 2.0.
I prefer explicit -- and more flexible -- than implicit and
inflexible.
are you citing line 2 of "the zen of python"[1] consciously? :)

Doubtful. I don't follow Pythonistas. However, if they are at all
serious about it, the irony involved in their *own* failure to be
explicit is delicious.
I always have the feeling that there could be something better than
ends, but untile I find it I'm happy with them.

I've never had that feeling. I've programmed in too many different
programming languages to feel that there's anything "wrong" with them.

-austin
 

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

Forum statistics

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

Latest Threads

Top