[Ironruby-core] Delegates (agian)

Dermot Hogan lists at ruby-forum.com
Thu Oct 25 17:51:06 EDT 2007


> I don't think we need RubyDelegate, you can write
> 
> x << method(:y)
> x << C.instance_method(:y).bind(obj)
> 
> or
> 
> x += method(:y)
> x += C.instance_method(:y).bind(obj)
> x -= method(:y)
> 
> if you will.
> 
> Blocks/procs should also work:
> 
> x { puts 'on click' }
> x << lambda { puts 'on click' }
> 
> Tomas

This isn't really what I mean. You need to be able to provide 
*syntactically* a delegate reference.

So in C#, we have x += new EventHandler(mymethod)

and in VB (I'm a bit rusty but something like this):

x += new EventHandler(AddressOf mymethod)

it's not the same as adding a method to an object. The object already 
*has* the method. What you need to to do is add the *delegate* (a 
typesafe function pointer) into the delegate chain.

I'm not an expert in any way in what you are doing in the DLR, but it 
doesn't seem to me that this does it. A delegate is a different thing 
from a method object. 'method' returns a method object which isn't the 
same as a delegate (an instance of the Delegate class) - at least, I 
can't add it into the delegate chain with the current version of IR.


Are you saying that 'method' will return a delegate? I'm not clear on 
this at all.



Dermot
-- 
Posted via http://www.ruby-forum.com/.


More information about the Ironruby-core mailing list