[Ironruby-core] Delegates (agian)

Dermot Hogan lists at ruby-forum.com
Fri Oct 26 13:38:39 EDT 2007

Curt Hagenlocher wrote:
> On 10/25/07, Dermot Hogan <lists at ruby-forum.com> wrote:
> I was trying to avoid writing this, but my inner pedant simply won't let
> go.  There's a difference between delegates and events.  A delegate is
> simply a bound function pointer, and it's perfectly legal to do a
> straightforward assignment as above.  An event is basically a published
> endpoint to which you subscribe and unsubscribe by adding and removing 
> your
> delegate.  The two are obviously related but not the same, and what we 
> seem
> to be talking about here specifically involves events.
> I feel much better now. :)

Yes. I've lumped them together ... there are two parts to this. First, 
the add-assignment (which isn't an assignment or an addition, but we'll 
let that pass). I don't really care whether this is a traditional += or 
a Ruby like << (which is more logical, I now think) so long as we have a 
delegate removal operator as well.

The second part is the delegate constructor syntax, that is how you pass 
the name of the event handler itself to the System::EventHandler 
constructor. All I want is a reasonable way to doing this without 
involving blocks. I'd be quite happy to settle for this:

x << System::EventHandler(self, :y)

whatever it is, the arguments have to be acceptable to the .NET 
System::EventHandler API. What I've been trying to point out is that 
different languages (VB, C#, IronPython, ...) do this in slightly 
different ways, but whatever they do, they don't use anything 
convoluted. However they do it, it's clear what's going on.

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

More information about the Ironruby-core mailing list