From: Robert Dober Date: 2007-01-20T21:06:49+09:00 Subject: Re: auto assign arguments? ------=_Part_170212_21542222.1169294806771 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/20/07, David Chelimsky wrote: > > On 1/20/07, Robert Dober wrote: > > On 1/19/07, Yukihiro Matsumoto wrote: > > > > > > Hi, > > > > > > In message "Re: auto assign arguments?" > > > on Sat, 20 Jan 2007 01:58:06 +0900, "David Chelimsky" < > > > dchelimsky@gmail.com> writes: > > > > > > > > > > > > Besides that, I think formal arguments of a method (including their > > > names) can be seen as part of class API. Allowing instance variables > > > as formal arguments seems like disclosing the internal issues. > > > > > > Yes exactly but by explicit declaration, so > > > > def set_length(@length) > > > > just would be a willful disclosure a little bit like > > attr_writer :length > > > > Thinking about this some more - I wasn't proposing this become part of > the API. Nor would I want to see this anywhere besides the > initializer. The proposal is that for initializers (only) you could Ah I see here we are really diverging. Are you aware that you propose different formal parameter symantics based on the method name? OTOH #initialize is a *special* method of course. But I am against it, would make the language more complicated. define (not reference pre-existing) instance variables: > > def initialize(@length) > end > > If this were allowed, there would be no need to expose the @ in RDoc. > RDoc could be tweaked to hide that, so you'd still just see: Again I fail to agree :(. If you exposed an instance variable like that would it not be desired for RDoc to document this? new(length) > > Note that RDoc is already hiding initialize (as an instance method) > and showing you new (as a class method), so this would just be an > addition to that transformation. > > So the proposed sugar would only be exposed to the intialize method > and anybody (human or machine) reading the class definition. > > David > Robert -- "The best way to predict the future is to invent it." - Alan Kay ------=_Part_170212_21542222.1169294806771--