Editing Topic: RCR275 Project: RCR | RCRchive home

RCR 275: Allow instance variables as method parameters

submitted by cyent on Tue Aug 17 2004 02:56:54 PM -0700

Status: rejected


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.

This idea has already been rejected. See https://rcrchive.net/rgarchive/rejected.html#rcr3

-- David Black


Add comments here




Back to RCRchive.


RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog