|
Re: Delegates, Components, and Simplexity
|
Posted: Sep 23, 2003 4:00 AM
|
|
It's all well and good that delegates are simpler in the basic case of calling a function directly. However, I have been really pissed off about delegates when writing real code.
The problem is that delegates only support calling a single method. The only state you can attach to this is the "this" pointer for the method (thank God for small favors: compare this to C++).
When I am trying to write moderately generic code, I almost always end up needing local state in the delegator, and what is the C# way of doing this? To create a whole new class, copy the neccessary variables over to it, and give a member method of the little inner class as the argument to the delegator. This is real simplexity!
The lack of anonymous inner classes alone makes C# into a more painful language than Java. I like to say: If you think writing anonymous inner classes is a kludge, try doing the same with top level classes.
BTW: Anders, as soon as C# anonymous functions are released, all my criticism falls. It should've been there from day one, though.
|
|