Fully dynamic d by opDotExp overloading

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Apr 17 13:56:41 PDT 2009


Leandro Lucarella wrote:
> Nick Sabalausky, el 17 de abril a las 16:38 me escribiste:
>> "Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
>> news:mailman.1171.1239998473.22690.digitalmars-d at puremagic.com...
>>> On Fri, Apr 17, 2009 at 03:54:47PM -0400, Nick Sabalausky wrote:
>>>> What
>>>> opDotExp is, is a tool of only occasional use that provides only a small
>>>> benefit, *and* ends up destroying a much more important tool: 
>>>> compile-time
>>>> checking on a class's members.
>>> Wouldn't the compile time checking remain the same on any class except
>>> the Variant (or whatever) which implements the new operator?
>>>
>>> If it is constrained to one type, the destruction seems like it would be
>>> acceptable. You can't trust much on a Variant at compile time anyway.
>>>
>> The problem is there would be no way to tell at a glance whether a given 
>> class uses opDotExp or not. You'd have to go look it up for every class. So, 
>> ok, we could solve that by requiring a different syntax for dynamic 
>> invokation. But we already have that: just pass a string to a dispatch 
>> function. 
> 
> This is like foreach. In C a for loop is a for loop, you are never calling
> a bizarre member function when looping. When you see code using foreach,
> you have to go look the variable definition to see if it's a real array to
> see what the looping is doing.
> 
> Do we need foreach? No, it's just syntax sugar. But I think it makes life
> much more easier...
> 
> 
> There is a lot of black magic already doing on that makes much harder to
> see what's really going on with a piece of code (operator overloading?).
> If you don't like that, you should probably stick to C =)
> 

It's more than just convenience; it's integration. Uniform form allows 
generic algorithms to operate on a variety of types. Somehow this 
argument keeps on being ignored in the discussion.

Andrei



More information about the Digitalmars-d mailing list