But... I don't want my delegates to be lazy - breeding advice

Gregor Richards Richards at codu.org
Tue Aug 22 12:16:59 PDT 2006


David Medlock wrote:
> I agree a keyword might be appropriate here, so as to ease the pain of 
> current C/C++ programmers moving to the Light side.
> 

IMHO it has nothing to do with C/C++ programmers moving over.  It's bad 
because:

1) It's not intuitive to cast expressions into anonymous delegates.

2) It causes ridiculous overload issues:
class A {...}  class B : A {...}
void q(A a); void q(void delegate() a);
void whatever() {
   B b = new B();
   q(b); // this should not be ambiguous, but is
}

3) If I understand, the expression will be evaluated multiple times, 
once every time you use it in the function, unless you copy it into a 
different value, which is just painful.

  - Gregor Richards



More information about the Digitalmars-d mailing list