Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7904
| From | "MikeP" <mp011011@some.org> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Implicit convervsion of bool to int: why? |
| Date | 2011-07-17 00:02 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <ivtqc2$ics$1@dont-email.me> (permalink) |
| References | <ivrll6$jh0$1@dont-email.me> <ael4275glbj0abvp20jbrm9qivttojbnv8@4ax.com> |
Robert Wessel wrote:
> On Sat, 16 Jul 2011 04:29:14 -0500, "MikeP" <mp011011@some.org> wrote:
>
>> Why can bool types be implicitly converted to ints? Wouldn't it be
>> better if a bool was a bool was a bool was a bool...? The
>> complementary question is also a curiosity: why can an int be
>> converted to a bool? I think the answer to the last question has to
>> do with "trueness" in C++ historically meaning "not zero" instead of
>> meaning "one".
>
>
> Why can shorts be implicitly converted to ints? Or ints to longs? Or
> floats to doubles? Or...?
Because the are numeric? (Now what do you think?).
>
> There are languages which have no implicit conversions.
The Haskell, Scheme, OCaml set, yes? Kinda makes me wanna cozy up to
functional languages. (Not ironic that they are called FUNCTIONAL, eh?).
> There's an
> argument that it's safer, although it certainly leads to a lot of
> extra typing. But a number of implicit conversion ("promotions") have
> always been part of C - the ones for bool are not really out of line
> given the usual way truth has been defined in C.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Implicit convervsion of bool to int: why? "MikeP" <mp011011@some.org> - 2011-07-16 04:29 -0500
Re: Implicit convervsion of bool to int: why? Krice <paulkp@mbnet.fi> - 2011-07-16 02:37 -0700
Re: Implicit convervsion of bool to int: why? "MikeP" <mp011011@some.org> - 2011-07-16 04:43 -0500
Re: Implicit convervsion of bool to int: why? BGB <cr88192@hotmail.com> - 2011-07-16 02:54 -0700
Re: Implicit convervsion of bool to int: why? Abhishek Padmanabh <abhishek.padmanabh@gmail.com> - 2011-07-16 18:52 +0100
Re: Implicit convervsion of bool to int: why? BGB <cr88192@hotmail.com> - 2011-07-16 23:03 -0700
Re: Implicit convervsion of bool to int: why? Abhishek Padmanabh <abhishek.padmanabh@gmail.com> - 2011-07-17 09:02 +0100
Re: Implicit convervsion of bool to int: why? BGB <cr88192@hotmail.com> - 2011-07-17 02:04 -0700
Re: Implicit convervsion of bool to int: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-16 22:28 -0500
Re: Implicit convervsion of bool to int: why? "MikeP" <mp011011@some.org> - 2011-07-17 00:02 -0500
Re: Implicit convervsion of bool to int: why? Robert Wessel <robertwessel2@yahoo.com> - 2011-07-17 02:04 -0500
Re: Implicit convervsion of bool to int: why? "MikeP" <mp011011@some.org> - 2011-07-17 05:38 -0500
Re: Implicit convervsion of bool to int: why? "MikeP" <mp011011@some.org> - 2011-07-20 05:14 -0500
Re: Implicit convervsion of bool to int: why? Niklas Holsti <niklas.holsti@tidorum.invalid> - 2011-07-30 13:18 +0300
Re: Implicit convervsion of bool to int: why? Niklas Holsti <niklas.holsti@tidorum.invalid> - 2011-07-31 13:48 +0300
Re: Implicit convervsion of bool to int: why? James Kanze <james.kanze@gmail.com> - 2011-07-20 11:08 -0700
csiph-web