On 2010-02-19 11:03:30 -0500, "Steven Schveighoffer"
<[email protected]> said:
//the cast is only there to shut up the stupid dmd!
int[] arr = cast(int[])([0, 1, 2]);
Yes, but a cast is a red flag. A simple appending of brackets is not.
It is well established that casts are to let you do things that in
most contexts are not a good idea. Brackets are not the same.
That's the theory. It doesn't quite work in practice because you
sometime have to cast to convert from one type to another (float to
int, base class to derived), or to make a literal of the type you want
(especially with array literals). Many usages of cast are safe, many
aren't. So seeing cast as a red flag doesn't really work, unfortunately.
Even SafeD allows cast, it just restricts it to safe usages.
--
Michel Fortin
[email protected]
http://michelf.com/