Hi all.
I'm very new to Ruby so this might be a bit of a shot in the dark,
but I'd like to suggest a minor change in the block 'end' syntax
that may help readability.
It's not a new idea, but it's something that I found helpfull
when reading Dylan code:
When the 'end' statement is used to close a code block, allow an
optional word or two of description.
They can be ignored by the interpreter, but it'd be usefull for
debugging for them to be matched.
Basicaly, any of the following would be acceptable:
def foo()
print "Foo!\n"
end
-or-
def foo()
print "Foo!\n"
end def
-or-
def foo()
print "Foo!\n"
end foo
-or-
def foo()
print "Foo!\n"
end def foo
---
An example class (from samples/list.rb) could become:
class MyList
def add_to_list(obj)
elt = MyElem.new(obj)
if @head
@tail.succ = elt
else
@head = elt
end if
@tail = elt
end add_to_list
def each
elt = @head
while elt
yield elt
elt = elt.succ
end while
end each
def to_s
str = "<MyList:\n";
for elt in self
str += elt.data.to_s + "\n"
end for
str += ">"
str
end to_s
end class MyList
Since the end modifier(?) is optional it won't break any previous work but I
think it'd significantly increase readability for larger classes.
Just an idea..
-Drew