From: gga Date: 2007-05-19T02:25:08+09:00 Subject: Re: Why not adopt "Python Style" indentation for Ruby? On May 18, 12:19 pm, "Eric Mahurin" wrote: > On 5/18/07, Yukihiro Matsumoto wrote: > > > Hi, > > > In message "Re: Why not adopt "Python Style" indentation for Ruby?" > > on Fri, 18 May 2007 22:01:13 +0900, Daniel Martin writes: > > > |Note that the Haskell folks have managed to evolve a language in which > > |python-like spacing can be used to mark the extent of discrete code > > |chunks, but so can traditional braces. > > > I admit Haskell syntax is much better than Python's. But I am not yet > > sure if it can be applied to Ruby. > > > matz. > > I've picked up on python in the last couple months and like the > indentation. In addition to forced readablity, I find another > practical benefit is that it eliminates hard to track down syntax > errors due to matching {}, begin/end, etc. In ruby, C, perl, etc > these errors can be painful to track down in a large file with lots of > blocks within blocks. No, it is just the other way around. Languages that use curly braces for indentation like C, Perl, etc. are EASY to work with once code is not properly factored and it extends outside a single page. Ruby is easy only when you use {, not so much when you use do/end, unfortunately, as most editors know nothing about it. Some good editors (emacs, for example), can tell you the context you are in the modeline with curly braces, but not so with other block indentation types. And most editors can easily find matching braces. No editor I am aware knows how to match indentation yet or do/end contexts (not that it could not be coded, thou). Python is a true nightmare to debug and understand once you have code that trails off a single page. A good example of these problems, for example, is the Maya Python API which is as ugly as it can be, using all of the ugliest things of python (tabulation using tabs, lots of underscore methods, lots of code that is not easily refactored, etc). Another problem with indentation only that has not been mentioned is that simple cut and paste of source code between two files is not guaranteed to work (and often will lead to a syntax error or worse, a runtime error). This to me is still a big no-no for indentation only, as most programmers *do* often cut and paste code from different contexts or files. With languages that use braces or Ruby's do/end you really don't have to worry about that, for the most part.