February 17, 2006
On 2006-02-16 22:01:18 -0800, Derek Parnell <derek@psych.ward> said:

> On Thu, 16 Feb 2006 23:28:20 -0500, Julio César Carrascal Urquijo wrote:
> 
>> S. Chancellor wrote:
>>> Why can't it be an enumerated type?
>>> 
>>> enum bool {
>>> true = 1,
>>> false = 0
>>> }
>> 
>> Because an integer can be converted to a enumerated type easily:
> 
> And you can do arithmetic with enums...
> 
> enum Bool
> {
>      True = 1,
>      False = 0
> }
> 
> void main()
> {
> 	Bool b1 = Bool.False;
> 	Bool b2 = Bool.True;
> 	int  b3 = b1 * 3 + (b2 - 7) / (b1 + Bool.True);
> }
> 
> But you should not be able to do that with booleans.

Says who?

Why shouldn't  you be able to do whatever you want with true and false provided you don't try to stuff them back into a bool?

February 17, 2006
On Sat, 18 Feb 2006 02:07:58 +1100, S. Chancellor <dnewsgr@mephit.kicks-ass.org> wrote:

> On 2006-02-16 22:01:18 -0800, Derek Parnell <derek@psych.ward> said:
>
>> On Thu, 16 Feb 2006 23:28:20 -0500, Julio César Carrascal Urquijo wrote:
>>
>>> S. Chancellor wrote:
>>>> Why can't it be an enumerated type?
>>>>  enum bool {
>>>> true = 1,
>>>> false = 0
>>>> }
>>>  Because an integer can be converted to a enumerated type easily:
>>  And you can do arithmetic with enums...
>>  enum Bool
>> {
>>      True = 1,
>>      False = 0
>> }
>>  void main()
>> {
>> 	Bool b1 = Bool.False;
>> 	Bool b2 = Bool.True;
>> 	int  b3 = b1 * 3 + (b2 - 7) / (b1 + Bool.True);
>> }
>>  But you should not be able to do that with booleans.
>
> Says who?

Obviously not *quite* everyone.

> Why shouldn't  you be able to do whatever you want with true and false provided you don't try to stuff them back into a bool?

Because they do not belong in the domain of numbers.
Because 'what is the square root of truth' is meaningless.
Because we don't allow '"cat" + "harry" / ( "bob" - "stupid")'.
Because 'false' is not zero, and 'true' is not one.
Because zero is not 'false' and one is not 'true'.

-- 
Derek Parnell
Melbourne, Australia
February 17, 2006
Walter Bright wrote:

> The others suggested why not remove bit?

Aw, crap! And I thought our unanimous opinion had something to do with it!  ;-(

> There's also the issue brought up here that perhaps D is accreting too many kludgy features. Bit is certainly a kludgy feature with too many special cases, and so things would definitely get simpler without it.

Amen to that.

> I definitely get the feeling that D is gaining momentum. Everywhere I go now, people have heard of D. They may not be writing programs in it yet, but they're aware of it and a lot of influential people are keeping tabs on its progress. 

Same here, too. There's pre-dawn light in the horizon, definitely!

> I've been invited to give yet another presentation on D at a major company tomorrow. 

May the Force be with you!
February 17, 2006
"Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message news:dt45me$2eca$1@digitaldaemon.com...
> Walter Bright wrote:
>> Should bit and bit[] be removed before 1.0?
> Yes! But I have one question: what will happen to bool, will it now be an alias to int? Will we get a real bool type? (Will if and while still expect int or will they expect bool?)

I was thinking of making bool a keyword and basic type along the lines of bool in C++.


February 17, 2006
Walter Bright wrote:
> "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message news:dt45me$2eca$1@digitaldaemon.com...
> 
>>Walter Bright wrote:
>>
>>>Should bit and bit[] be removed before 1.0?
>>
>>Yes! But I have one question: what will happen to bool, will it now be an alias to int? Will we get a real bool type? (Will if and while still expect int or will they expect bool?)
> 
> 
> I was thinking of making bool a keyword and basic type along the lines of bool in C++. 
> 

Great! Not ideal but much much better than now.
February 17, 2006
S. Chancellor wrote:
> Well yeah, if you want to do that...  Are you trying to write messed up code?

My point it's that the enum solution isn't any better than an alias to bit or a typedef to int which was the other proposed solution:

typedef int bool;

A bool type still needs to be implemented in the compiler to be a real Boolean type.
February 17, 2006
In article <dt36tu$1lg3$2@digitaldaemon.com>, Walter Bright says...
>
>I think the basic type bit has been a failure. It's a substantial increase in the compiler and runtime complexity to support it. Nobody seems happy about bit being a boolean type. There's no reasonable way to take a pointer to a bit, meaning that out and inout bit parameters are inconsistent and kludgy.
>
>Should bit and bit[] be removed before 1.0?
>
>There is a place for bit[] as a library type, though.
>
>So what do people think?
>
>

If overloding of the opFunction for typedefs were allowed then bit[] could be done as a typedef (this would also permit lots of other cool things)


February 17, 2006
Walter Bright wrote:
> I think the basic type bit has been a failure. It's a substantial increase in the compiler and runtime complexity to support it. Nobody seems happy about bit being a boolean type. There's no reasonable way to take a pointer to a bit, meaning that out and inout bit parameters are inconsistent and kludgy.
> 
> Should bit and bit[] be removed before 1.0?
> 
> There is a place for bit[] as a library type, though.
> 
> So what do people think?  

Another definate Yes vote for removal (and replacement with a true boolean type) here!

(From a long-time newsgroup lurker who remembers the bit v bool debate)

Les Baker
February 17, 2006
"Derek Parnell" <derek@psych.ward> wrote in message news:op.s44h81h56b8z09@ginger.vic.bigpond.net.au...
> Because they do not belong in the domain of numbers.
> Because 'what is the square root of truth' is meaningless.
> Because we don't allow '"cat" + "harry" / ( "bob" - "stupid")'.
> Because 'false' is not zero, and 'true' is not one.
> Because zero is not 'false' and one is not 'true'.

I agree with everything but the last two lines.  If there's anything that irritates me, it's when a language makes it very difficult to convert between ints and bools.  While I will accept the fact that bools abstract the ideas of "true" and "false," I think it's still useful to allow them to be represented by their true, numerical representation.


February 17, 2006
On Sat, 18 Feb 2006 03:17:18 +1100, Walter Bright <newshound@digitalmars.com> wrote:

>
> "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message
> news:dt45me$2eca$1@digitaldaemon.com...
>> Walter Bright wrote:
>>> Should bit and bit[] be removed before 1.0?
>> Yes! But I have one question: what will happen to bool, will it now be an
>> alias to int? Will we get a real bool type? (Will if and while still
>> expect int or will they expect bool?)
>
> I was thinking of making bool a keyword and basic type along the lines of
> bool in C++.

Oh come on, you can do better than that.



-- 
Derek Parnell
Melbourne, Australia