Casting an expression to bool means testing for 0 or !=0 for arithmetic types

Pluto pluto at planets.not
Sun Aug 1 02:37:16 PDT 2010


== Quote from Jonathan M Davis (jmdavisprog at gmail.com)'s article
> On Saturday 31 July 2010 20:15:58 Jason Spencer wrote:
> > == Quote from Dmitry Olshansky (dmitry.olsh at gmail.com)'s article
> >
> [...snip]
> >
> > Just a thought.
> > Jason
> I honestly don't think that exception handling is a particularly expensive
> solution in most cases. When dealing with an error, it's likely to either be
> related to I/O (be it an actual I/O error or input from a user or file) or a
> logic error in the code.
I have seen code which tries toInt and then does toFloat in the catch. Not sure
whether it was just bad code (looks like it though) but there are probably some
examples where people really don't know what kind of data they are handling and
use std.conv to try.
Not really sure about that now that I think about it.
~~
:Pluto



More information about the Digitalmars-d-learn mailing list