In article <m2d7c5vxnl.fsf / zip.local.thomases.com>, Dave Thomas wrote:
>So, could we change parameter passing slightly so that if an instance
>method has a formal parameter starting with an '@' sign, the incoming
>value is assigned directly to the corresponding instance variable?
>Using this scheme I could write the above as:
>
>  class Msg
>    def initialize(@name, @type, @txt)
>    end
>  end

I do not like the idea. Adding magic just to save typing is only a good
idea if the magic is beautiful. This magic is not.

IMHO, typing is not so bad. Most people type faster than they think
anyway (Stephen Hawkins is probably an exception.)

If you do need to save some typing, one idea (inspired by Mathieu Bouchard)
is to create a function that assigns local variables to instance varaibles.

def locals_to_iv(bin)
   eval("local_variables", bin).each {|v| eval("@#{v}=#{v}", bin)}
end

Now you can just write

class Test
	def initialize(name, type, txt)
		locals_to_iv(binding)
		...

Of course, if the goal is to save typing, you may want to name this 
function "l" instead ;)

// Niklas