F
Frasier Mruby
James, thank you for you fast response.
I didn't propose to get rid of the "END" like python does, but wondered
if there could be cleaner syntax to as an alternative for "END".
Ruby code is reasonable or readable with "END". And I agree a better
editor would help to find matching END, but still wonder if there could
be room to make the ruby code cleaner by considering other syntax to
replace "END".
What I was saying in previous post is to free up the braces "{}" out of
block syntax to replace "END". For blocks, besides "do...end", use
something else like "[], or /**/. e.g.:
class Foo
def bar(b)
c = b+1
if b is not nil
if c > 10
c++
if c %2 == 0
c += 3
print c
end
end
if d < 9
d += 2
print d
end
end
a = [1, 2]
a.each {|num| print num }
end
end
# tries to clean up the "END"s
class Foo
def bar(b) {
c = b+1
if b is not nil {
if c > 10 {
c++
if c %2 == 0 {
c += 3
print c
}
}
if d < 9 {
d += 2
print d
}
}
a = [1, 2]
a.each [|num| print num ]
a.each (|num| print num )
a.each < |num| print num >
a.each /* |num| print num */
a.each /# |num| print num #/
...
}
end
If {} can represent a bock, then personally it might also readable to
use [] and syntax above to denote blocks.
I also like the idea that "END" is optional for one line if, like:
if a > 0 :
print a
I can live with "END" in ruby, now just want to express an opinion or
wish to make the ruby code more cleaner, and more programmer attracted.
I didn't propose to get rid of the "END" like python does, but wondered
if there could be cleaner syntax to as an alternative for "END".
Then don't do that. Seriously. Twisty conditionals is a code smell.
(Having fought with deep hierarchies of YAML and HAML, the lack of an
explicit "end" token doesn't really help in complex documents; in fact,
it can be detriment. Sometimes explicit is better than implicit.)
Ruby code is reasonable or readable with "END". And I agree a better
editor would help to find matching END, but still wonder if there could
be room to make the ruby code cleaner by considering other syntax to
replace "END".
What I was saying in previous post is to free up the braces "{}" out of
block syntax to replace "END". For blocks, besides "do...end", use
something else like "[], or /**/. e.g.:
class Foo
def bar(b)
c = b+1
if b is not nil
if c > 10
c++
if c %2 == 0
c += 3
print c
end
end
if d < 9
d += 2
print d
end
end
a = [1, 2]
a.each {|num| print num }
end
end
# tries to clean up the "END"s
class Foo
def bar(b) {
c = b+1
if b is not nil {
if c > 10 {
c++
if c %2 == 0 {
c += 3
print c
}
}
if d < 9 {
d += 2
print d
}
}
a = [1, 2]
a.each [|num| print num ]
a.each (|num| print num )
a.each < |num| print num >
a.each /* |num| print num */
a.each /# |num| print num #/
...
}
end
If {} can represent a bock, then personally it might also readable to
use [] and syntax above to denote blocks.
I also like the idea that "END" is optional for one line if, like:
if a > 0 :
print a
I can live with "END" in ruby, now just want to express an opinion or
wish to make the ruby code more cleaner, and more programmer attracted.