How does D improve design practices over C++?
Janderson
ask at me.com
Thu Nov 6 20:48:15 PST 2008
Jarrett Billingsley wrote:
> On Thu, Nov 6, 2008 at 11:32 PM, Bill Baxter <wbaxter at gmail.com> wrote:
>>> C++ is a huge language, and not many know the entire language. Case in
>>> point, you didn't know what Delegates where yet many C++ programmers use
>>> them frequently. Its better if the language makes it easy rather then
>>> requiring the programmer to do something to be correct. Just like expecting
>>> an email program to have spell check your emails. Modern languages should
>>> do the same.
>> C++ doesn't have "delegates". It has member function pointers. I
>> don't think that's changed. boost::bind (now std::tr1::bind in some
>> places) gives you a way to bundle a member function pointer with an
>> object pointer in a delegate-like way, but I don't think anybody calls
>> those delegates. At least they didn't used to.
>>
>> I don't know who came up with the word "delegate" but I find it to be
>> a terrible match for what they actually are.
>> - "one appointed or elected to represent others"?
>> It's a kind of a stretch. [/rant]
>
> I don't know if C# had them first or what, but the name.. fits
> somewhat better there. C#'s delegates are something like D's
> delegates combined with a signals and slots implementation. So you
> can think of a delegate as not being a method itself, but rather a
> representative to all the objects+methods that have subscribed to it.
> It's still not really a good fit ;) But you make do with what you
> have.
C# delegates are closer to what I was originally taught where. There's
also the "Delegation pattern" which offers another clue:
http://en.wikipedia.org/wiki/Delegation_pattern
-Joel
More information about the Digitalmars-d
mailing list