dynamic classes and duck typing

Bill Baxter wbaxter at gmail.com
Tue Dec 1 13:07:00 PST 2009


On Tue, Dec 1, 2009 at 1:01 PM, Bill Baxter <wbaxter at gmail.com> wrote:
> On Tue, Dec 1, 2009 at 12:38 PM, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>> On Tue, 01 Dec 2009 15:06:27 -0500, Pelle Månsson <pelle.mansson at gmail.com>
>> wrote:
>>
>>> Steven Schveighoffer wrote:
>>
>>>>  Isn't opBinary almost identical to opDispatch?  The only difference I
>>>> see is that opBinary works with operators as the 'symbol' and dispatch works
>>>> with valid symbols.  Is it important to distinguish between operators and
>>>> custom dispatch?
>>>>  -Steve
>>>
>>> opBinary is a binary operator, opDispatch can be anything. I think they
>>> should be kept separate.
>>
>> You could say the same thing about dynamic properties.  How come we don't
>> split those out as opProperty?
>
> That's because of what Andrei pointed out:  &a.b .
> The compiler can't tell if you want a delegate to the method b, or the
> address of a property b.

... but maybe the syntax for "the function itself" should be distinct
from "dereference" anyway.
I can't think of any reason the two need to use the same syntax other
than that &func was called a "function pointer" back in C.
There's no case for "generic code" needing it to be the same syntax as
far as I can tell.

--bb



More information about the Digitalmars-d mailing list