www.digitalmars.com         C & C++   DMDScript  

D - Functions and Delegates

reply Marcelo Fontenele S Santos <msantos pobox.com> writes:
Just my 2 cents.

I think that function pointers and delegates should be interchangeble 
and use the same syntax.

int function( int ) foo;

int bar( int i )
{
}

foo = bar; // ok function address

class O
{
   static int bar( int i )
   {
   }

   int baz( int i )
   {
   }
}

O o = new O;

foo = O.bar; // ok function address
foo = O.baz; // error no object pointer
foo = o.baz; // ok encapsulates object pointer and method adress

This would make this a lot easier to understand and to implement 
signal/slot functionality in the language or in a library.

-- 
Marcelo Fontenele S Santos <msantos pobox.com>
Feb 05 2003
parent "Walter" <walter digitalmars.com> writes:
I intend to revisit this issue, as many have requested this. -Walter
Feb 09 2003