Cannot implicitly convert delegate to function

Chris Nicholson-Sauls ibisbasenji at gmail.com
Thu Apr 27 11:55:54 PDT 2006


Lionello Lunesu wrote:
> (Yes, obviously I could put the function inside a class, but that's just 
> adding overhead that shouldn't be necessary in the first place)

Could always wrap it in an anonymous delegate:
#import std.format;
#void _disp_putc( dchar c ) {
#    int i = cast(int)c;
#    if (c >= 0x80)
#        i = '?';
#//    disp_putc(i);
#}
#void disp_writef(...) {
#    std.format.doFormat(delegate void(dchar c){_disp_putc(c);},_arguments,_argptr);
#}

But still, for something this trivial its just overkill.  I do believe I recall Walter 
saying that, at some unknown future point, he intends function pointers and delegates to 
merge into a single type, but I don't know what the precise plan of action (if any) might 
be to that end.  It would certainly help solve soft spots like this one, though.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d-learn mailing list