From: craig duncan Date: 2005-02-14T07:38:09+09:00 Subject: Re: mandatory braces Johannes Ahl-mann wrote: > hi, > > i've been playing around with ruby a bit and have a proposal to make. > i am sure that ruby won't adopt it right away and maybe it goes too much > against the ruby way. also, if this has been discussed earlier here, i > apologize for not researching ;-)) > > if ruby made braces (the round ones ;-) mandatory this would produce > some very nice effects and break nothing except for backward compatibility > (i think). regarding the backward compatibility one could even introduce > a new command-line switch to explicitely activate the "new" syntax. > a few things would become possible: > > - differentiation between method bindings and method applications, i.e. > "function1(function2)" instead of "function1(method(:function2)) > - procedure objects could be treated similarly to functions: > "myproc()" instead of "myproc.call()" > - ruby code would look more uniform, because at the moment the mixing > of braces and no-braces drives me crazy *gg* > > - on the negative side this would force braces for methods "yield", > "print", "puts", "break", etc. > > please tell me whether this is a bad idea, > > Johannes I agree (with others) that this exact idea isn't so good. Why should you have to use parens when a method has no args? But the one flaw that has bothered me about ruby is that _too much_ flexibility in parsing is allowed. I'd like it if parens were required around a method call's arguments. The savings in leaving them off i find less than desirable as i (personally) find it _harder_ to parse things out, visually. Not to mention that i think the following is ridiculous: s='abc' => "abc" irb(main):002:0> (s.length -1).downto(0) { |i| p i } ArgumentError: wrong number of arguments (1 for 0) from (irb):2:in `length' from (irb):2 irb(main):003:0> (s.length - 1).downto(0) { |i| p i } 2 1 0 => 2