Why not move cast to the standard library?

Yigal Chripun yigal100 at gmail.com
Thu Sep 24 10:56:23 PDT 2009


On 24/09/2009 19:35, downs wrote:
> With all the neat template tricks we have in 2.0, and since we're
> widely redefining the syntax anyway, why not deprecate the current
> cast syntax and move it into object.d as a library function?
>
> So instead of cast(Foo) bar; you would say cast!Foo(bar); .. save on
> a keyword and demonstrate language power at the same time.
>
> What sez ye?

vote++;

casts and especially implicit casts are evil. The programmer should 
always prefer calling a conversion function instead of relying on casts. 
for example, for FP -> integer conversion the user may need to change 
the rounding/truncation behavior.



More information about the Digitalmars-d mailing list