Why not move cast to the standard library?

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 24 10:47:21 PDT 2009


On Thu, 24 Sep 2009 12:35:22 -0400, downs <default_357-line at yahoo.de>  
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?

What is the benefit?  Does it allow anything that isn't possible today  
(aside from using cast as a member, which I find not that worthy)?

What I'd much rather have is directed casts, even if they are supported by  
the compiler, such as the casting features of C++ (i.e. const_cast and  
static_cast).

I actually prefer the compiler to handle the casting versus templates to  
cut down on template instantiation bloat.

-Steve



More information about the Digitalmars-d mailing list