dynamic classes and duck typing

Bill Baxter wbaxter at gmail.com
Tue Dec 1 16:39:31 PST 2009


On Tue, Dec 1, 2009 at 4:22 PM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> Bill Baxter Wrote:
>
>> Good counterpoints to my argument.  So I give up on that line.
>>
>> Here's another, how do you implement the opBinary_r operators with opDispatch?
>
> Kinda cooky, but what about this:
>
> a + b -> b.opDispatch!("r+" )(a)

That's what I had in mind too, so I guess it's not so hard to guess.
Really the _r convention is also kooky.  We're just more used to that.
 So this isn't really a strong argument for separating opBinary out of
opDispatch.

But that is part of why I was asking about opIn -- if opIn_r's
spelling remains "opIn_r" then we will have both conventions to deal
with.  Not so good.  But if that one's changing to opDispatch!"in"
also, then we'll need opSomething!"rin".  Which is kookier than "r+",
I think, but at least maintains consistency.

But there is a problem.  It means you can't opDispatch on a method called "rin".
So I think there would have to be some non-symbol char in the "r"
prefix used.  Maybe "r:+", "r:+=", "r:in".  Or just a space -- "r +",
"r in", ... etc.
But now it's a notch less intuitive.

--bb



More information about the Digitalmars-d mailing list