Submitted by Malte (Sun Jul 18 11:07:10 UTC 2004)
Introduce the keyword until_eof, which you use like this:
module XY until_eof
It is used to let the end of the source file be a replacement for the keyword end.
You often have ruby source files looking like this:
(First line) class XY
# lots of indented # code goes here
(Last line) end
Such files have got two disadvantages:
<li>You have lots of indented code, i.e. waste of space, and </li> <li>When looking at such a file and reading the word "end", you have to look at the beginning of the file to know what it is for.</li>
Introduce the keyword until_eof, which works like this:
module XY until_eof
which is a replacement for
module XY
# Lots of code within XY
end
Comments | Current voting | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
Use a folding editor and most of the issues with this go away. -- Austin Ziegler
Hm. So why has Ruby got a clear syntax? We don't need it using editors with syntax highlighting. --Malte
To try to be clearer: "Issues." I don't personally see a real issue here. Look at Diff::LCS; I have not only divided the module up in multiple pieces within a single file, but I have taken advantage of the ability to simply do: "module Diff::LCS" after I have done "module Diff\nmodule LCS" earlier in the file. This reduces the amount of indentation (necessary, because I also have a "class << self" present). I also use Vim, which folds the Ruby code for me so that I only need to see the parts that I am immediately concerned with. I don't see an issue with the way that Ruby does this, especially not one that requires a change to the Ruby interpreter just to accommodate a stylistic preference. -- Austin Ziegler
I'm opposed to this RCR because it's a kind of workaround for something that I don't think is a problem. Every language has *some* constraints and requirements as to its appearance. I don't think a language-level construct can or should be introduced to cater to all tastes. -- David Black
Theoretically, it would be quite easy to implement in the core the ability to close all lexical node definitions at the eof / __END__ keyword, if they aren't already closed. This would make it harder to catch certain bugs, but such a feature would probably be turned off in a "strict" mode. I don't like the keyword implementation, however, as Ruby doesn't need any more keywords, and could probably do with fewer. --Zallus Kanite