From: "David A. Black" Date: 2005-02-14T00:29:35+09:00 Subject: Re: mandatory braces Hi -- On Sun, 13 Feb 2005, 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()" I don't think that's desireable, and probably not feasible. Consider: def x; end x = lambda {} x() # which is it? Not an example of great programming, but definitely legal. > - 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, It's a bad idea :-) I agree that the mixing of styles looks bad, and I wish people would stick reasonably close to traditional style, which generally does not use empty parens except for super(), one-line method definitions, and meth() as an alternative to self.meth. I fear that that battle is being lost on several fronts (camelcase, extra (), tab stops more than 2, etc.), but I still root for it. Anyway -- in addition to adding visual clutter, and being redundant (since the . already means that a method is going to be called), I think mandatory () would weaken attribute/accessor semantics. You'd end up with: person.age() which just shouts "This is a method call with zero arguments!" without adding any new information, since person.age already tells you that. (Assuming there's no argument after it :-) David -- David A. Black dblack@wobblini.net