RCR 275: Allow instance variables as method parameters
Submitted by cyent (Tue Aug 17 18:08:54 UTC 2004)
Abstract
Allow syntax like...
class Foo
def current_style( a, b, c)
@a = somefunc( a, b)
@b = b
@@c = c
end
def proposed_style( a, @b, @@c)
@a = somefunc(a, @b)
end
end
foo = Foo.new
foo.proposed_style( 1, 2, 3)
Results in foo.b == 2 and Foo.c == 3
Problem
Very often method parameters (especially those of "def initialize" are assigned to @instance variables. As a short cut, you should be able to put the @instance variable as an argument name meaning that it is instantly assigned on entry.
Proposal
If a variable name with an instance '@' or class variable '@@' sigil appears in the formal arguments of a method, the semantics equivalent to assignment to that @instance of @@class variable.
Analysis
It would require a syntax change.
Implementation
|
Strongly opposed |
2 |
Opposed |
0 |
Neutral |
0 |
In favor |
0 |
Strongly advocate |
0 |
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
This idea has already been rejected. See https://rcrchive.net/rgarchive/rejected.html#rcr3
-- David Black