www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What is the official view on the use of cast() ?

reply "antiAlias" <fu bar.com> writes:
Is cast() considered something to be used as sparingly as possible? For
instance, is it there to get you out of a jamb? Or, is cast() expected to be
used regularly, and as a matter of course?
Aug 30 2004
parent "Vathix" <vathixSpamFix dprogramming.com> writes:
"antiAlias" <fu bar.com> wrote in message
news:cgvqdh$2ove$1 digitaldaemon.com...
 Is cast() considered something to be used as sparingly as possible? For
 instance, is it there to get you out of a jamb? Or, is cast() expected to
be
 used regularly, and as a matter of course?
I'd say it depends. It's ok when working with void* or void[], when casting object types and checking for null, and when casting different number types (int, float, long; etc). Other than that, it should be avoided for safety.
Aug 30 2004