Thread overview
Incorrect type signature matching?
Oct 26, 2004
David Medlock
Oct 27, 2004
David Medlock
October 26, 2004
alias bit delegate( in char[] , out uint ) f_type;

class A
{
  f_type    member;
  this( f_type f ) { member = f; }
}


bool myfunct( in char[] txt, out uint len )
{
  return false;
}


void main( char[][] arg )
{
  A var = new A( cast(f_type)myfunct );
  A var = new A( myfunct );
}

Why does this not compile?
The type signatures appear to match.
(it does not work using 'function' in place of delegate above either)

I hope im not overlooking something obvious(thats what I get for programming at home after programming all day at work!)
October 26, 2004
"David Medlock" <amedlock@nospam.org> escribió en el mensaje
news:clm8ei$3b1$1@digitaldaemon.com...
| alias bit delegate( in char[] , out uint ) f_type;
|
| class A
| {
|   f_type    member;
|   this( f_type f ) { member = f; }
| }
|
|
| bool myfunct( in char[] txt, out uint len )
| {
|   return false;
| }
|
|
| void main( char[][] arg )
| {
|   A var = new A( cast(f_type)myfunct );
|   A var = new A( myfunct );
| }
|
| Why does this not compile?
| The type signatures appear to match.
| (it does not work using 'function' in place of delegate above either)
|
| I hope im not overlooking something obvious(thats what I get for
| programming at home after programming all day at work!)

This is not a bug. There're 2 things here: first, you need to use new A( & myfunct ). Notice the "&". No cast either.

Second, a delegate is a function with an enclosing frame (or something like
that). Anyway, myfunct should be, a) a nested function, or b) a non-static
member function. Either way, your code will work.
To make it work as it is right now, change f_type to be function instead of
delegate, and don't forget the "&".

-----------------------
Carlos Santander Bernal


October 27, 2004
Carlos Santander B. wrote:
> "David Medlock" <amedlock@nospam.org> escribió en el mensaje news:clm8ei$3b1$1@digitaldaemon.com...
> | alias bit delegate( in char[] , out uint ) f_type;
> |
> | class A
> | {
> |   f_type    member;
> |   this( f_type f ) { member = f; }
> | }
> |
> |
> | bool myfunct( in char[] txt, out uint len )
> | {
> |   return false;
> | }
> |
> |
> | void main( char[][] arg )
> | {
> |   A var = new A( cast(f_type)myfunct );
> |   A var = new A( myfunct );
> | }
> |
> | Why does this not compile?
> | The type signatures appear to match.
> | (it does not work using 'function' in place of delegate above either)
> |
> | I hope im not overlooking something obvious(thats what I get for
> | programming at home after programming all day at work!)
> 
> This is not a bug. There're 2 things here: first, you need to use new A( & myfunct ). Notice the "&". No cast either.
> 
> Second, a delegate is a function with an enclosing frame (or something like that). Anyway, myfunct should be, a) a nested function, or b) a non-static member function. Either way, your code will work.
> To make it work as it is right now, change f_type to be function instead of delegate, and don't forget the "&".
> 
> -----------------------
> Carlos Santander Bernal 
> 
> 

Thanks Carlos.