How does D improve design practices over C++?
Michel Fortin
michel.fortin at michelf.com
Wed Nov 12 05:49:45 PST 2008
On 2008-11-09 09:04:00 -0500, Christopher Wright <dhasenan at gmail.com> said:
> Michel Fortin wrote:
>> On 2008-11-07 02:42:20 -0500, Walter Bright <newshound1 at digitalmars.com> said:
>>
>>> The difference between D delegates and boost::bind for member functions
>>> is that D delegates bind to the specific virtual function when the
>>> delegate is created, while boost::bind binds when the delegate is
>>> called. The former is, of course, more efficient when the delegate gets
>>> called more than once.
>>
>> But the later makes it possible to call the same member function on
>> various object instances (which may resolve to different code for
>> virtual functions). I find that capability lacking in D.
>
> You can do it in D, but only with templates. And it's ugly.
>
> I must admit, I've never encountered a situation in which I wanted a
> pointer to a member function. What situations did you encounter this
> in? Why were, say, interfaces insufficient?
In the D/Objective-C bridge when I recieve a call from the Objective-C
side and I need to dispatch it to the corresponding method of the given
D object.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list