On Thu, 18 Dec 2014 23:18:16 +0000
"Adam D. Ruppe via Digitalmars-d" <[email protected]> wrote:

> On Thursday, 18 December 2014 at 23:06:12 UTC, ketmar via 
> Digitalmars-d wrote:
> > the only thing this will help is to hide bugs, i believe.
> 
> On the contrary, I find explicit casts hide bugs. Suppose you 
> write:
> 
> size_t a = cast(int) b;
> 
> It will compile and run. It'll mostly work. But the cast to int 
> probably wasn't intended (it was probably written in 32 bit code 
> and not correctly ported to 64 bit).
> 
> How often do we also write auto a = cast(T) b;? The difference 
> would be the type is written on the left side instead of the 
> right. Might make an important differnce when calling functions.
> 
> I think the auto cast is a win all around.

p.s. with functions it's even more puzzling: now i have to look at the
function signature to deduce the actual type. if such calls are rare,
there is no need for "auto casts". if such calls are frequent, write a
wrapper function or template!

Attachment: signature.asc
Description: PGP signature

Reply via email to