Safer casts

Yigal Chripun yigal100 at gmail.com
Sun May 11 11:31:31 PDT 2008


Dee Girl wrote:
> 
> I am not sure I understood all how D templates work. But how it seems
> is this. Please correct if it is wrong. If reduce takes a template
> argument then expands a loop each time in client code. If reduce as
> you want takes a delegate argument then there is only one loop but
> there is one indirect call for each iteration.
> 
> Question is which one is better. Conceptually they have same power.
> There are details of performance. I think first one is best because
> really offers you both. The second only limits your choice. But they
> have same power, why would you hate one and love another? Thank you,
> Dee Girl
> 

read my other reply about time vs. space.
I prefer a delegate since to me it looks cleaner. I don't know how
Andrei implemented it, but either the template inlines stuff and the
benefit would be less time more space (again, the balance can change due
to linker/compiler)
if not than it would be the same as the delegate version. only it'll
bloat the executable since for each unique delegate there will be a copy
of the template.
If my understanding here is wrong, feel free to correct me. [Janice?]

--Yigal



More information about the Digitalmars-d mailing list