On Wed, Nov 15, 2006 at 07:09:50AM +0900, Marcel Molina Jr. wrote:
> >> class Setter; def set=(value) 1 end end
> => nil
> >> Setter.new.set = 'hello'
> => "hello"
> >> Setter.new.send(:set=, 'hello')
> => 1
[...] 
> I am just curious: Is the implicit difference between direct invocation
> and invocation with send (or call) a deliberate api design or an unintended over sight?

It seems deliberate (as you say, there's no gain in making foo.send(:bar=, 1)
behave like foo.bar = 1, and it'd require an extra runtime check).

> (P.S. I spent some time mucking around in parse.y and eval.c trying to answer
> this myself and couldn't find any clues. If anyone knows, I'd appreciate
> being directed to the part of the code that makes sure to return the argument
> rather than the result of the method call for setter methods)


rb_eval (eval.c)

      case NODE_ATTRASGN:
	{
[...]
	    rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,block,scope,0,self);
	    result = argv[argc-1];
	    ^^^^^^^^^^^^^^^^^^^^^
	    ^^^^^^^^^^^^^^^^^^^^^
	}
	break;

instead of  result = rb_call(...).

-- 
Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby