Thread overview | |||||
---|---|---|---|---|---|
|
October 26, 2004 Incorrect type signature matching? | ||||
---|---|---|---|---|
| ||||
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 Re: Incorrect type signature matching? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Medlock | "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 Re: Incorrect type signature matching? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | 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.
|
Copyright © 1999-2021 by the D Language Foundation