Date: Fri, 2 Mar 2001 10:10:02 +0900 Posted: Thu, 1 Mar 2001 16:47:45 -0800 From: "chris" <nospam / 6666666.com> Reply-To: ruby-talk / ruby-lang.org Sender: nosuzuki / e-mail.ne.jp Don't know whether this discussion would be better here or on the email list. My searches haven't found a previous discussion on this topic - appologies if there was one. --- I find Ruby to very a very enjoyable language. My other liking is Python. Particularly enjoyable to me is how the Tab style indenting works. I find that not needing braces or "end" statements *dramatically* cuts down on the screen space occupied by code. Instead of 40 lines with 10 or 15 braces/"ends", I have 40 lines of full code. Nice. It reads easier and is easier to work with (my opinion.) I'm aware that there are many people who don't like the Python style and that is OK. I respect that. One of the things I have noticed about Ruby is that it accomodates different styles in a way that doesn't break anything and allows people to (within bounds) use what they like. My question for all is, why not create an option in Ruby that would allow the parser to accept code that used indentation instead of "end" statements? Would this be really all that hard? I, myself, couldn't do it, but I get the feeling that a relatively simple change to the parser would make it possible. Specifically, I would envision some code that goes before the current parser code that simply reads the file and uses the indentation levels to insert "end"s where needed. Then the code would continue on to the normal parser. All of this would be turned on/off with a switch or setting. Those who don't like it never need to use it. How about it? Does anybody think this is doable and are there others who would like to see it? chris Note that the Ruby "end" statements do not have to occur on separate lines. If you want to save screen space, you can write if (predicate) then X else Y end for i in (0..n) do function(i) end all on one line in Ruby, which could be difficult to do with an indentation-based syntax. A central beauty of Ruby is that most everything is EXPLICIT. Naming conventions are enforced: variable names indicate their function and their scope (constant, local, global, etc.) Blocks are clearly delimited in a robust easy-to-read manner. The simplicity and orthogonality of the language means that (contrary to your claim) there's generally only one or two good ways to accomplish something in Ruby. As a result, it is very easy to read Ruby code and immediately understand what's going on. For this reason, adding a second indentation-based syntax to Ruby would destroy the language. (If anything, I would urge that the designer to remove the optional elements of the Ruby syntax eg., require "then" after "if", etc.) Eric