D vs. C#

Dave Dave_member at pathlink.com
Fri Nov 24 07:54:23 PST 2006


Ary Manzana wrote:
> Walter Bright escribió:
>> Dave wrote:
>>> I don't think D interfaces would have any less performance potential 
>>> than any other language using interfaces (or even C++ MI)?
>>
>> Since D interfaces are implemented just like C++ MI, there is no 
>> performance difference between the two.
> 
> I wrote that because of the recent discusion about iterators. I copy and 
> paste:
> 
> Bill Baxter said:
>  > That's like C++'s way.  Iterator is basically a generalized pointer.
>  > The other proposal is more like Java/Python/C#'s way, where the
>  > iterator  is like a pointer that knows it's own limits.
> 
> Walter Bright said:
>  > I think the C++ like way will be a lot more efficient, and I think it
>  > will work.
> 
> So now I wonder what "a lot more efficient" means.
> 
> Some people (like me) think it's very hard to understand C++ iterator 
> semantic, and it's also harder to implement your own iterator.  And if 
> doing it that way dosen't improve your performance, then you are loosing 
> easy development against a little better performance (which you can 
> always have by not using iterators at all).

Ah, I think I see your concerns with interfaces and iterators.

 From what was discussed, I don't think something like C#'s IEnumerable interface would be needed. 
Generic UDT templates could be built with something like C#'s GetEnumerator, MoveNext, Reset and 
Current w/o using IEnumerable (these would be 'built-in'). Then they could be used via the standard 
foreach syntax with implicit type inference, and avoid the overhead of the interface.

I think what Walter has in mind would be the best of both worlds really.



More information about the Digitalmars-d mailing list