September 09, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to J. Daniel Smith | Sorry, I don't. :( "J. Daniel Smith" <J_Daniel_Smith@HoTMaiL.com> wrote in message news:bji345$muf$1@digitaldaemon.com... > The last time this came up, I posted some comments about a line of thinking > that says bool arguments are overused. If you buy into that argument (and it does have some merit), then not being able to take the address of bool isn't so bad. > > Dan > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bjgv8a$23cu$1@digitaldaemon.com... > > [Apologies up-front for the shameless egotism in trying out my new signature. Sorry chaps.] > > > > The argument against bool as a bit is that a bit cannot have its address taken. That's an acceptable limitation, since everyone understands bits > are > > a sub-unit of the "lowest addressable unit", i.e. a byte. However, it's > not > > in the least bit reasonable for a bool, and will lead to a profusion of Bool, boolean, Boolean, _Bool types. > > > > The argument against bool as a small type (i.e. 8 or 16-bits) is that > there > > are unavoidable inefficiencies in the following > > > > int i = . . .; > > bool b = i; // The compiler must replace this with bool b = i != 0; > > > > I grant you this is less compelling, but this is a serious (from > efficiency) > > flaw of C++, and D is supposed to be answering the flaws in C++ - > especially > > the easy ones - so I just don't think doing the same thing is acceptable. > > > > Naturally if implicit conversions to and from integers are disallowed this > > kind of thing goes away. If people want implicit conversions, then sizeof(bool) is an important matter. > > > > Either way, it's about time we heard from the big guy on this. Walter? > > > > Oh, as for ~ I think it's entirely inappropriate to have a bit-wise > operator > > on a type whose *entire* reason for being is to represent logical notions. > > No ~ for bool for me please. (Another reason to move away from it being an > > alias for bit.) The reason to disallow it is simple, it is not > appropriate. > > Languages are not suffering from a lack of malapplicable operators. Quite > > the reverse. And I say this as one who has formerly committed all kinds of > > transgressions in C++ over the years. I once implemented the ++ operator > for > > a string class! > > > > -- > > Matthew Wilson > > > > STLSoft moderator and C++ monomaniac (http://www.stlsoft.org) > > Contributing editor, C/C++ Users Journal > > (www.synesis.com.au/articles.html#columns) > > > > "An Englishman by birth, a Yorkshireman by the grace of God" -- Michael Gibbs > > > > -------------------------------------------------------------------------- > -- > > --- > > > > > > > > "John Boucher" <John_member@pathlink.com> wrote in message news:bjgsj3$1vdf$1@digitaldaemon.com... > > > I like bool as a bit rather than as an int because by definition a bool > is > > > limited to a set of two values, but an int can hold oh so many more. > > > > > > My opinion is that with a bool the two operations not (!) and complement > > (~) > > > should return the same value, which is not always true with ints. Of > > course > > > maybe it doesn't make sense to perform complement on bools anyway, but I > > see no > > > reason not to allow it. > > > > > > John Boucher > > > The King had Humpty pushed. > > > > > > |
September 09, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | > I thought Walter made it so that you can take the address of a bit and pass > it by reference? I'd forgotten that discussion. > Bool should be a 1-bit type that the compiler can store in a byte or int if > it wants. You should not have any guarantee in the language regarding the size of bool. If you, the programmer, need to know, use the .size property. I'm 100% with you there, apart from the .size thing. I'm not sure one would even want to take the size of a bool. (Of course, when writing serialsiation code it might be necessary. Hmm. Thinking) |
September 09, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Boucher | That would be nice. I was just talking about the (likely) case where implicit int<=>bool conversions are allowed (sigh). "John Boucher" <John_member@pathlink.com> wrote in message news:bjic5b$14j7$1@digitaldaemon.com... > If the language is strongly typed, shouldn't this produce a compile-time error? > I hope it would. Why add a bool type except to type it strongly? > > > int i = . . .; > > bool b = i; // The compiler must replace this with bool b = i != 0; |
September 10, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Fine. |
October 31, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bjgv8a$23cu$1@digitaldaemon.com... > The argument against bool as a bit is that a bit cannot have its address taken. Except that now you can! |
October 31, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Can a bit be involved in implicit integral promotions? If so, give me a strong bool type! "Walter" <walter@digitalmars.com> wrote in message news:bnupbd$gi8$1@digitaldaemon.com... > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bjgv8a$23cu$1@digitaldaemon.com... > > The argument against bool as a bit is that a bit cannot have its address taken. > > Except that now you can! > > |
November 01, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <matthew-hat@-stlsoft-dot.-org> wrote in message news:bnupsk$he1$1@digitaldaemon.com... > Can a bit be involved in implicit integral promotions? Yes, it can be promoted, but not demoted. > > If so, give me a strong bool type! > > "Walter" <walter@digitalmars.com> wrote in message news:bnupbd$gi8$1@digitaldaemon.com... > > > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bjgv8a$23cu$1@digitaldaemon.com... > > > The argument against bool as a bit is that a bit cannot have its address > > > taken. > > > > Except that now you can! > > > > > > |
November 01, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:bnv1n0$s56$1@digitaldaemon.com... > > "Matthew Wilson" <matthew-hat@-stlsoft-dot.-org> wrote in message news:bnupsk$he1$1@digitaldaemon.com... > > Can a bit be involved in implicit integral promotions? > > Yes, it can be promoted, but not demoted. I suspected as much. :( > > If so, give me a strong bool type! I refer the honourable gentleman to the presumptuous directive I gave some moments ago |
November 01, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <matthew-hat@-stlsoft-dot.-org> wrote in message news:bnv224$siq$1@digitaldaemon.com... > > > If so, give me a strong bool type! > I refer the honourable gentleman to the presumptuous directive I gave some moments ago I understand how you feel about it, but I think we'll just have to agree to disagree! |
November 01, 2003 Re: bool == bit? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > "Matthew Wilson" <matthew-hat@-stlsoft-dot.-org> wrote in message news:bnv224$siq$1@digitaldaemon.com... > > > > If so, give me a strong bool type! > > I refer the honourable gentleman to the presumptuous directive I gave some > > moments ago > > I understand how you feel about it, but I think we'll just have to agree to > disagree! Bad Walter! No dessert for you |
Copyright © 1999-2021 by the D Language Foundation