D - bool == bit?
- w (6/6) Sep 07 2003 I don't know if this has been discussed before, and I couldn't find a "s...
- Vathix (7/13) Sep 07 2003 It was origionally bit, but bool was recently added as an alias to bit.
- Matthew Wilson (12/18) Sep 07 2003 bit was originally to be used. bool is now an alias for bit.
- John Boucher (8/8) Sep 07 2003 I like bool as a bit rather than as an int because by definition a bool ...
- Matthew Wilson (40/48) Sep 07 2003 [Apologies up-front for the shameless egotism in trying out my new
- Riccardo De Agostini (8/12) Sep 08 2003 for
- Matthew Wilson (7/18) Sep 08 2003 Quite
- J. Daniel Smith (17/67) Sep 08 2003 The last time this came up, I posted some comments about a line of think...
- Matthew Wilson (13/96) Sep 08 2003 Sorry, I don't. :(
- Sean L. Palmer (13/28) Sep 08 2003 I thought Walter made it so that you can take the address of a bit and p...
- Matthew Wilson (7/12) Sep 08 2003 if
- John Boucher (4/6) Sep 08 2003 John Boucher
- Matthew Wilson (5/9) Sep 08 2003 That would be nice. I was just talking about the (likely) case where
- Walter (3/5) Oct 31 2003 Except that now you can!
- Matthew Wilson (4/9) Oct 31 2003 Can a bit be involved in implicit integral promotions?
- Walter (4/17) Oct 31 2003 Yes, it can be promoted, but not demoted.
- Matthew Wilson (5/10) Oct 31 2003 I suspected as much. :(
- Walter (4/7) Oct 31 2003 I understand how you feel about it, but I think we'll just have to agree...
- Matthew Wilson (3/10) Oct 31 2003 Bad Walter! No dessert for you
- Sean L. Palmer (33/40) Nov 01 2003 Boolean algebra is a distinct and separate algebra from real or integer
- Helmut Leitner (8/23) Nov 01 2003 wouldn't it be nice to include such things as
- Juan C (8/31) Nov 01 2003 Indeed, booleans are _not_ numbers, they're _booleans_ there should be n...
- Luna Kid (6/33) Nov 01 2003 Let me join the current meeting of the bool gang, guys... ;)
- Sean L. Palmer (51/71) Nov 01 2003 Yeah, but I couldn't think of anything in integer arithmetic to correspo...
- w (1/1) Sep 09 2003 Fine.
- Ilya Minkov (14/17) Nov 02 2003 Do you really need to unfold a discussion again? This will lead nowhere....
- Matthew Wilson (9/26) Nov 02 2003 Well, firstly, my post was a long time ago. Several weeks at least
- Roberto Mariottini (11/16) Nov 04 2003 I agree. Completely.
- Matthew Wilson (1/2) Nov 04 2003 You are a man of singular wisdom. ;)
- Helmut Leitner (6/22) Nov 04 2003 Here it is:
- Luna Kid (8/11) Nov 04 2003 Cool!
- Helmut Leitner (6/18) Nov 05 2003 Now I know why my server was green in the face and wouldn't
- Sean L. Palmer (23/40) Nov 03 2003 So just say that bool/bit store as one machine word, which contains up t...
I don't know if this has been discussed before, and I couldn't find a "search" in this forum, so... Is "bit" D's boolean type? If it is, OK. But, if some people use bit, others use int and others define a custom type, i'm afraid D will follow C's path (Let the developer choose its boolean type. Then every library has a typedef for bool or BOOL. After the mess, define a type with a strange name like _Bool...)
Sep 07 2003
It was origionally bit, but bool was recently added as an alias to bit. "w" <w_member pathlink.com> wrote in message news:bjg0d7$nke$1 digitaldaemon.com...I don't know if this has been discussed before, and I couldn't find a"search"in this forum, so... Is "bit" D's boolean type? If it is, OK. But, if some people use bit,others useint and others define a custom type, i'm afraid D will follow C's path(Let thedeveloper choose its boolean type. Then every library has a typedef forbool orBOOL. After the mess, define a type with a strange name like _Bool...)
Sep 07 2003
bit was originally to be used. bool is now an alias for bit. There are *several* people who do not like this, but sadly Walter's not one of them. Not that we don't keep trying to convince him every now and than. I personally think that bool should be a distinct type, of the size of int, and which cannot engage in implicit conversions to and from integer types. Sadly, my sway is marginal, at best. :( "w" <w_member pathlink.com> wrote in message news:bjg0d7$nke$1 digitaldaemon.com...I don't know if this has been discussed before, and I couldn't find a"search"in this forum, so... Is "bit" D's boolean type? If it is, OK. But, if some people use bit,others useint and others define a custom type, i'm afraid D will follow C's path(Let thedeveloper choose its boolean type. Then every library has a typedef forbool orBOOL. After the mess, define a type with a strange name like _Bool...)
Sep 07 2003
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.
Sep 07 2003
[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. Ofcoursemaybe it doesn't make sense to perform complement on bools anyway, but Isee noreason not to allow it. John Boucher The King had Humpty pushed.
Sep 07 2003
"Matthew Wilson" <matthew stlsoft.org> ha scritto nel messaggio news:bjgv8a$23cu$1 digitaldaemon.com...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 ++ operatorfora string class!In case you thought you were in for some prize, I've heard that someone was as crazy as to implement bitshift operators on I/O streams!! :) BTW, what in the world did that ++ do when applied to a string? Just curious... Ric
Sep 08 2003
"Riccardo De Agostini" <riccardo.de.agostini email.it> wrote in message news:bjhcei$2nku$2 digitaldaemon.com..."Matthew Wilson" <matthew stlsoft.org> ha scritto nel messaggio news:bjgv8a$23cu$1 digitaldaemon.com...QuiteLanguages are not suffering from a lack of malapplicable operators.ofthe reverse. And I say this as one who has formerly committed all kindswastransgressions in C++ over the years. I once implemented the ++ operatorfora string class!In case you thought you were in for some prize, I've heard that someoneas crazy as to implement bitshift operators on I/O streams!! :) BTW, what in the world did that ++ do when applied to a string? Just curious...This is one of several of my former C++ criminality that're going into Appendix B of my book. You'll have to buy it! ;)
Sep 08 2003
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 bitsarea sub-unit of the "lowest addressable unit", i.e. a byte. However, it'snotin 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 thatthereare 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 (fromefficiency)flaw of C++, and D is supposed to be answering the flaws in C++ -especiallythe 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-wiseoperatoron 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 notappropriate.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 ++ operatorfora 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...isI like bool as a bit rather than as an int because by definition a boollimited 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. Ofcoursemaybe it doesn't make sense to perform complement on bools anyway, but Isee noreason not to allow it. John Boucher The King had Humpty pushed.
Sep 08 2003
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 ofthinkingthat 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...acceptable.[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 bitsarea sub-unit of the "lowest addressable unit", i.e. a byte. However, it'snotin 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 thatthereare 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 (fromefficiency)flaw of C++, and D is supposed to be answering the flaws in C++ -especiallythe easy ones - so I just don't think doing the same thing isthisNaturally if implicit conversions to and from integers are disallowednotions.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-wiseoperatoron a type whose *entire* reason for being is to represent logicalanNo ~ for bool for me please. (Another reason to move away from it beingQuitealias for bit.) The reason to disallow it is simple, it is notappropriate.Languages are not suffering from a lack of malapplicable operators.ofthe reverse. And I say this as one who has formerly committed all kindsbooltransgressions in C++ over the years. I once implemented the ++ operatorfora 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 aiscomplementlimited 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 (!) andI(~)should return the same value, which is not always true with ints. Ofcoursemaybe it doesn't make sense to perform complement on bools anyway, butsee noreason not to allow it. John Boucher The King had Humpty pushed.
Sep 08 2003
I thought Walter made it so that you can take the address of a bit and pass it by reference? 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. Sean "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. That's an acceptable limitation, since everyone understands bitsarea sub-unit of the "lowest addressable unit", i.e. a byte. However, it'snotin 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 thatthereare 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 (fromefficiency)flaw of C++, and D is supposed to be answering the flaws in C++ -especiallythe 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.
Sep 08 2003
I thought Walter made it so that you can take the address of a bit andpassit by reference?I'd forgotten that discussion.Bool should be a 1-bit type that the compiler can store in a byte or intifit wants. You should not have any guarantee in the language regarding the size of bool. If you, the programmer, need to know, use the .sizeproperty. 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)
Sep 08 2003
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;John Boucher The King had Humpty pushed.
Sep 08 2003
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-timeerror?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;
Sep 08 2003
"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!
Oct 31 2003
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!
Oct 31 2003
"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...address"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 itstaken.Except that now you can!
Oct 31 2003
"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...I suspected as much. :(Can a bit be involved in implicit integral promotions?Yes, it can be promoted, but not demoted.I refer the honourable gentleman to the presumptuous directive I gave some moments agoIf so, give me a strong bool type!
Oct 31 2003
"Matthew Wilson" <matthew-hat -stlsoft-dot.-org> wrote in message news:bnv224$siq$1 digitaldaemon.com...I understand how you feel about it, but I think we'll just have to agree to disagree!I refer the honourable gentleman to the presumptuous directive I gave some moments agoIf so, give me a strong bool type!
Oct 31 2003
"Matthew Wilson" <matthew-hat -stlsoft-dot.-org> wrote in message news:bnv224$siq$1 digitaldaemon.com...someI refer the honourable gentleman to the presumptuous directive I gaveIf so, give me a strong bool type!tomoments agoI understand how you feel about it, but I think we'll just have to agreedisagree!Bad Walter! No dessert for you
Oct 31 2003
Boolean algebra is a distinct and separate algebra from real or integer algebras. It supports a much smaller set of operations and possible values. I guess the closest numeric representation would be a modulo-2 integer arithmetic. And while I would ordinarily want D to as much as possible allow us as users to create such low-level types ourselves, this still falls into the category of "everyone will want it", and it's a good idea to standardize such a thing before too many incompatible implementations are created. Boolean Numeric Equivalent =================== and * or min or max or saturating + xor modular + But not many of the other operations (division, etc) make sense in a boolean context. For instance, what boolean value would you use to represent the result of true divided by false? ;) Implicit conversions, while handy, can also lead to hard-to-find logical errors that the compiler won't warn you about. After having worked with very low level assembly, I find it annoying that C/C++ always promote the result of any sized integer operation to int or long... that means the semantics of certain operations cannot be supported by hardware byte registers; it's constantly promoting the bytes up to int behind your back. That kind of thing can sure impact the performance of a tight inner loop. Bit, as a concept, is also a quite valuable tool, having many potential uses above and beyond what D currently supports. I believe I rambled on about such a while back. For instance, named slices of a bit array could be used as bitfields, if conversion between bit array slice and integral types were allowed. Sean "Walter" <walter digitalmars.com> wrote in message news:bnvk4b$1l5k$1 digitaldaemon.com..."Matthew Wilson" <matthew-hat -stlsoft-dot.-org> wrote in message news:bnv224$siq$1 digitaldaemon.com...meI refer the honourable gentleman to the presumptuous directive I gave soIf so, give me a strong bool type!tomoments agoI understand how you feel about it, but I think we'll just have to agreedisagree!
Nov 01 2003
"Sean L. Palmer" wrote:Boolean algebra is a distinct and separate algebra from real or integer algebras. It supports a much smaller set of operations and possible values. I guess the closest numeric representation would be a modulo-2 integer arithmetic. And while I would ordinarily want D to as much as possible allow us as users to create such low-level types ourselves, this still falls into the category of "everyone will want it", and it's a good idea to standardize such a thing before too many incompatible implementations are created. Boolean Numeric Equivalent =================== and * or min or max or saturating + xor modular +wouldn't it be nice to include such things as nand nor given their real world importance? -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Nov 01 2003
Indeed, booleans are _not_ numbers, they're _booleans_ there should be no implicit conversions in either direction. The common use of the symbols "0" and "1" to indicate the boolean values is not to be taken as anything but a convenience, which is why we as nerds usually use "false" and "true". Boolean should be strongly typed and I don't care about how it is represented behind the scenes. If you also want a one-bit number (whatever that's worth) then you have the bit. But a bit is _not_ a boolean! In article <3FA3964B.1881EEC7 chello.at>, Helmut Leitner says..."Sean L. Palmer" wrote:Boolean algebra is a distinct and separate algebra from real or integer algebras. It supports a much smaller set of operations and possible values. I guess the closest numeric representation would be a modulo-2 integer arithmetic. And while I would ordinarily want D to as much as possible allow us as users to create such low-level types ourselves, this still falls into the category of "everyone will want it", and it's a good idea to standardize such a thing before too many incompatible implementations are created. Boolean Numeric Equivalent =================== and * or min or max or saturating + xor modular +wouldn't it be nice to include such things as nand nor given their real world importance? -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Nov 01 2003
Let me join the current meeting of the bool gang, guys... ;) (However, also let me thank Walter for at least the bit --> bool alias thing. This makes inconsistent code at least syntactically close to the right thing...) Sz. "Juan C" <Juan_member pathlink.com> wrote in message news:bo0nv2$6vp$1 digitaldaemon.com...Indeed, booleans are _not_ numbers, they're _booleans_ there should be no implicit conversions in either direction. The common use of the symbols "0" and "1" to indicate the boolean values is not to be taken as anything but a convenience, which is why we as nerds usually use "false" and "true". Boolean should be strongly typed and I don't care about how it is represented behind the scenes. If you also want a one-bit number (whatever that's worth) then you have the bit. But a bit is _not_ a boolean! In article <3FA3964B.1881EEC7 chello.at>, Helmut Leitner says..."Sean L. Palmer" wrote:Boolean algebra is a distinct and separate algebra from real or integer algebras. It supports a much smaller set of operations and possible values. I guess the closest numeric representation would be a modulo-2 integer arithmetic. And while I would ordinarily want D to as much as possible allow us as users to create such low-level types ourselves, this still falls into the category of "everyone will want it", and it's a good idea to standardize such a thing before too many incompatible implementations are created. Boolean Numeric Equivalent =================== and * or min or max or saturating + xor modular +
Nov 01 2003
Yeah, but I couldn't think of anything in integer arithmetic to correspond to those! ;) I refer the interested reader to a more respectable authority on the subject: http://mathworld.wolfram.com/BooleanFunction.html http://mathworld.wolfram.com/BooleanAlgebra.html This blurb emphasises the importance of NAND: "The NAND operation is the basic logical operation performed by the solid-state transistors ("NAND gates") that underlie virtually all integrated circuits and modern computers. The first axiom system based on NAND was given by Henry Sheffer in 1913. In their landmark tome, Whitehead and Russell (1927) promoted NAND as the appropriate foundation for axiomatic logic. " I know that personally I find (A AND B) and (A AND NOT B) very useful for dealing with masks. The closest integer operation to this would be saturating subtraction. In my day-to-day work I rarely feel the need for NAND though. const uint Rmask = 0x000000FF; const uint Gmask = 0x0000FF00; const uint Bmask = 0x00FF0000; const uint Amask = 0xFF000000; const uint Rshift = 0; const uint Gshift = 8; const uint Bshift = 16; const uint Ashift = 24; uint RGBA(ubyte r,ubyte g,ubyte b,ubyte a) { return (r << Rshift) | (g << Gshift) | (b << Bshift) | (a << Ashift); } uint SetR(uint color, ubyte newR) { return (color & ~Rmask) | (r << Rshift); } uint SetG(uint color, ubyte newG) { return (color & ~Gmask) | (r << Gshift); } uint SetB(uint color, ubyte newB) { return (color & ~Bmask) | (r << Bshift); } uint SetA(uint color, ubyte newA) { return (color & ~Amask) | (r << Ashift); } Sean "Helmut Leitner" <helmut.leitner chello.at> wrote in message news:3FA3964B.1881EEC7 chello.at..."Sean L. Palmer" wrote:values.Boolean algebra is a distinct and separate algebra from real or integer algebras. It supports a much smaller set of operations and possiblefallsI guess the closest numeric representation would be a modulo-2 integer arithmetic. And while I would ordinarily want D to as much as possible allow us as users to create such low-level types ourselves, this stillareinto the category of "everyone will want it", and it's a good idea to standardize such a thing before too many incompatible implementationscreated. Boolean Numeric Equivalent =================== and * or min or max or saturating + xor modular +wouldn't it be nice to include such things as nand nor given their real world importance?
Nov 01 2003
Matthew Wilson wrote:I personally think that bool should be a distinct type, of the size of int, and which cannot engage in implicit conversions to and from integer types. Sadly, my sway is marginal, at best. :(Do you really need to unfold a discussion again? This will lead nowhere. An alias does the job. Besides, people shall want to have an array of boolean, and will want to behave like a bitarray, or rather like an array of flags! Bit and bool should be the same. Divorcing them will also introduce a tiny but unrequiered conceptual complexity into the language, and will open a great deal of other questions, as to what conversion rules should be! It's like touching a wesp nest. After all, there are so many *important* issues! We even have a faulty division operator, a falty switch, and a ton of other faulty C leftovers, which shall not further be dealt with, for obvious reasons. And the bool question has long reached a fragile consensus. -eye
Nov 02 2003
Well, firstly, my post was a long time ago. Several weeks at least Second, implicit conversions to/from numeric and non-numeric types is a flaw, just as much as switch, etc. Just because a majority of people think that ease of coding is more important than correctness and maintainability, does not mean the issue is moot, merely boring and unpopular. "Ilya Minkov" <minkov cs.tum.edu> wrote in message news:bo31b9$a7o$1 digitaldaemon.com...Matthew Wilson wrote:int,I personally think that bool should be a distinct type, of the size oftypes.and which cannot engage in implicit conversions to and from integerSadly, my sway is marginal, at best. :(Do you really need to unfold a discussion again? This will lead nowhere. An alias does the job. Besides, people shall want to have an array of boolean, and will want to behave like a bitarray, or rather like an array of flags! Bit and bool should be the same. Divorcing them will also introduce a tiny but unrequiered conceptual complexity into the language, and will open a great deal of other questions, as to what conversion rules should be! It's like touching a wesp nest. After all, there are so many *important* issues! We even have a faulty division operator, a falty switch, and a ton of other faulty C leftovers, which shall not further be dealt with, for obvious reasons. And the bool question has long reached a fragile consensus. -eye
Nov 02 2003
In article <bo39ao$m2h$1 digitaldaemon.com>, Matthew Wilson says...Well, firstly, my post was a long time ago. Several weeks at least Second, implicit conversions to/from numeric and non-numeric types is a flaw, just as much as switch, etc. Just because a majority of people think that ease of coding is more important than correctness and maintainability, does not mean the issue is moot, merely boring and unpopular.I agree. Completely. Can we add a page on the D Wiki for the "boolean != bit" party? This issue comes back every one-two months, and always the same things are said about it. A big summary of "bool != bit" advantages can be set up, so that the misbeliving can be redirected there for more information. I have another proposal: All D standard libraries should use the standard alias "bool" every time a truth value is handled. This will ease the bit -> bool conversion when is eventually done. Ciao
Nov 04 2003
I agree. Completely.You are a man of singular wisdom. ;)
Nov 04 2003
Roberto Mariottini wrote:In article <bo39ao$m2h$1 digitaldaemon.com>, Matthew Wilson says...Here it is: http://www.prowiki.org/wiki4d/wiki.cgi?BooleanNotEquBitWell, firstly, my post was a long time ago. Several weeks at least Second, implicit conversions to/from numeric and non-numeric types is a flaw, just as much as switch, etc. Just because a majority of people think that ease of coding is more important than correctness and maintainability, does not mean the issue is moot, merely boring and unpopular.I agree. Completely. Can we add a page on the D Wiki for the "boolean != bit" party?This issue comes back every one-two months, and always the same things are said about it. A big summary of "bool != bit" advantages can be set up, so that the misbeliving can be redirected there for more information.-- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Nov 04 2003
"Helmut Leitner" <leitner hls.via.at> wrote in message news:3FA77603.6E09CC95 hls.via.at...Cool! I put some stupid preliminary stuff there, please delete! ;) [This Wikiing is real fun indeed.. I've done that now for the first time. Hope the server survived my 20-something consecutive updates... ;)] Cheers, Sz.Can we add a page on the D Wiki for the "boolean != bit" party?Here it is: http://www.prowiki.org/wiki4d/wiki.cgi?BooleanNotEquBit
Nov 04 2003
Luna Kid wrote:Now I know why my server was green in the face and wouldn't speak to me that morning... :-) -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.comCool! I put some stupid preliminary stuff there, please delete! ;) [This Wikiing is real fun indeed.. I've done that now for the first time. Hope the server survived my 20-something consecutive updates... ;)]Can we add a page on the D Wiki for the "boolean != bit" party?Here it is: http://www.prowiki.org/wiki4d/wiki.cgi?BooleanNotEquBit
Nov 05 2003
So just say that bool/bit store as one machine word, which contains up to 32 or so bools in the same word. That takes care of storage. As Walter knows, a bit* is a regular pointer plus as many bits as are required to address the number of bits in a machine word., log2(n), as is a reference to bit. This is one of the reasons you cannot assume a pointer to be castable back and forth between int and pointer types without losing information The bit itself is either 0 or 1 and always lives in an addressible hardware bit somewhere, either a cpu flag or memory location. Conversion from bit to larger types it seems should be possible, but not implicitly? Maybe it should act more like a boolean and less like a 1-bit integer. If you want to do integer math on a bit, cast to int (0 or 1) or uint (0 or ~0/) and maybe explicitly specify the true and false results. Maybe the ? : operator could be the only way to convert a bit to an integer, and compilers expected to "figure out" how to do things like (a < b) ? -1 : 0 as efficiently as possible (use setlt, decrement). I'm for rationals as the result of integer division, the rationals being implicitly convertible to int and return the int portion of the result of the division operation. Sean "Ilya Minkov" <minkov cs.tum.edu> wrote in message news:bo31b9$a7o$1 digitaldaemon.com...Matthew Wilson wrote:int,I personally think that bool should be a distinct type, of the size oftypes.and which cannot engage in implicit conversions to and from integerSadly, my sway is marginal, at best. :(Do you really need to unfold a discussion again? This will lead nowhere. An alias does the job. Besides, people shall want to have an array of boolean, and will want to behave like a bitarray, or rather like an array of flags! Bit and bool should be the same. Divorcing them will also introduce a tiny but unrequiered conceptual complexity into the language, and will open a great deal of other questions, as to what conversion rules should be! It's like touching a wesp nest. After all, there are so many *important* issues! We even have a faulty division operator, a falty switch, and a ton of other faulty C leftovers, which shall not further be dealt with, for obvious reasons. And the bool question has long reached a fragile consensus. -eye
Nov 03 2003