April 20, 2005
Bent Rasmussen, you still around ?

Charlie

"Ben Hinkle" <Ben_member@pathlink.com> wrote in message news:d44993$1uki$1@digitaldaemon.com...
> Last september Bent Rasmussen (there might be others but this http://www.digitalmars.com/d/archives/digitalmars/D/10156.html is the one
I
> found) suggested adding
> bit eof()
> bit isOpen()
> to InputStream and
> bit isOpen()
> void flush()
> void close()
> to OutputStream. Those requests seem reasonable to me. Any complaints?
Otherwise
> I'll include them with my std.stream bugfixes.
>
> -Ben
>
>


April 20, 2005
"Charlie" <charles@jwavro.com> wrote in message news:d46ajl$15n0$1@digitaldaemon.com...
> Bent Rasmussen, you still around ?
>
> Charlie

slightly off-topic, this reminds me that for years when I was a kid my dentist would call me "Bent" and I never knew if she was joking or not and I was too intimidated to correct her.


April 20, 2005
> slightly off-topic, this reminds me that for years when I was a kid my dentist would call me "Bent" and I never knew if she was joking or not and
I
> was too intimidated to correct her.


Want us to teach her a lesson ?

Regulators .... mount up.

:)

P.S., hey can you get me a discount on matlab :) ?  I never got to use it at uni and now its really expensive :S.

"Ben Hinkle" <bhinkle@mathworks.com> wrote in message news:d46bq6$16qn$1@digitaldaemon.com...
>
> "Charlie" <charles@jwavro.com> wrote in message news:d46ajl$15n0$1@digitaldaemon.com...
> > Bent Rasmussen, you still around ?
> >
> > Charlie
>
> slightly off-topic, this reminds me that for years when I was a kid my dentist would call me "Bent" and I never knew if she was joking or not and
I
> was too intimidated to correct her.
>
>


April 20, 2005
In article <42664D91.1070405@nospam.org>, Georg Wrede says...
>
>All I hope is that we're consistent!!
>
>The boss of a sw company I recently raved about D to, took a look at the sources delivered with DMD, and he was unimpressed.
>
>First he had a hard time figuring out this "bit" stuff. (I know, I know!)
>
>Then he was amazed about bit and bool being both used.

Personally, I never use the 'bool' alias as I feel it's misleading.  I do use 'true' and 'false' however, just because I find that much more useful than '1' and '0'.


Sean


April 20, 2005
On Wed, 20 Apr 2005 13:16:27 -0500, Joshua Cearley <jtech@ezoob.com> wrote:
> the only reason I can think of ever wanting a String type is for OO. You would be able to say ThisIsSomeString.strip() like you can in Ruby or Java.

And D:

char[] strip(char[] input) {}
char[] a;
char[] b;
b = a.strip();

It's a lovely little feature of arrays. I'm hoping it's extended to 'int' etc.

Regan
April 21, 2005
"Sean Kelly" <sean@f4.ca> wrote in message news:d46it3$1d9d$1@digitaldaemon.com...
> In article <42664D91.1070405@nospam.org>, Georg Wrede says...
>>
>>All I hope is that we're consistent!!
>>
>>The boss of a sw company I recently raved about D to, took a look at the sources delivered with DMD, and he was unimpressed.
>>
>>First he had a hard time figuring out this "bit" stuff. (I know, I know!)
>>
>>Then he was amazed about bit and bool being both used.
>
> Personally, I never use the 'bool' alias as I feel it's misleading.  I do
> use
> 'true' and 'false' however, just because I find that much more useful than
> '1'
> and '0'.

Out of curiosity, does the D spec actually say what the values of bit are? I thought they were true and false since the .init value is false. The types of 1 and 0 are ints that get implicitly converted to true/false.


April 21, 2005
Ben Hinkle wrote:

> Out of curiosity, does the D spec actually say what the values of bit are? I thought they were true and false since the .init value is false. The types of 1 and 0 are ints that get implicitly converted to true/false. 

The values of bit are 0 and 1. "true" is a const bit 1, and "false" a 0.
(to make things more exciting, those constants are D compiler-internal)

And when you for instance put a 2 into a bit, it gets the value of 1...
(as does any non-zero integer you put into it. 0 is still 0, or "false")

It's truly confused. But it works the same as the _Bool type does, in C.
--anders

PS.
    assert(typeid(typeof(true)) == typeid(bit));
    assert(typeid(typeof(false)) == typeid(bit));
    assert(bit.sizeof == 1);
    assert(true == 1);
    assert(false == 0);
April 21, 2005
"Anders F Björklund" <afb@algonet.se> wrote in message news:d48gqn$7kq$1@digitaldaemon.com...
> Ben Hinkle wrote:
>
>> Out of curiosity, does the D spec actually say what the values of bit are? I thought they were true and false since the .init value is false. The types of 1 and 0 are ints that get implicitly converted to true/false.
>
> The values of bit are 0 and 1. "true" is a const bit 1, and "false" a 0. (to make things more exciting, those constants are D compiler-internal)

By 0 and 1 I mean the values with type int, since that is how D parses the
constants 0 and 1. I agree a 1 with type bit is defined to be "true" so they
are indistinguishable. The constants 0 or 1 (with type int) are implicitly
converted to false or true (which are by definition 0 or 1 with type bit).
So I still think it's accurate to say the values of bit are true and false
since that implies the correct type while saying the values are 0 and 1
confuse the type bit with int. To illustrate
assert(typeid(typeof(1)) == typeid(bit));
fails.

> And when you for instance put a 2 into a bit, it gets the value of 1... (as does any non-zero integer you put into it. 0 is still 0, or "false")

I can't assign 2 to a variable of type bit. It says it can't convert int to bit. Do you mean cast(bit)2?

> It's truly confused. But it works the same as the _Bool type does, in C. --anders
>
> PS.
>     assert(typeid(typeof(true)) == typeid(bit));
>     assert(typeid(typeof(false)) == typeid(bit));
>     assert(bit.sizeof == 1);
>     assert(true == 1);
>     assert(false == 0);

These make sense to me. true and false are implicitly convertible to 1 and 0 (the ints).


April 21, 2005
Ben Hinkle wrote:

> So I still think it's accurate to say the values of bit are true and false since that implies the correct type while saying the values are 0 and 1 confuse the type bit with int. To illustrate
> assert(typeid(typeof(1)) == typeid(bit));
> fails.

That's correct. I guess one *should* say the "bit" is true and false.
Like many others, I am more comfortable with using the alias "bool".

>>And when you for instance put a 2 into a bit, it gets the value of 1...
>>(as does any non-zero integer you put into it. 0 is still 0, or "false")
> 
> I can't assign 2 to a variable of type bit. It says it can't convert int to bit. Do you mean cast(bit)2?

Sorry, yes - that is what I meant. Thus, bit is not an integer type ?
(which is easy to believe if you just hear the term "bit" being used)


I still don't know what all the fuss about calling it "bit" is about.
(why it wasn't named "bool" in the first place... probably the size ?)

Oh well, that's been decided since long. Time to move on, for sure.
I'll try not to mutter, when next newcomer to D wonders about this...

--anders
April 21, 2005
On Thu, 21 Apr 2005 18:23:37 +0200, Anders F Björklund wrote:

> Ben Hinkle wrote:
> 
>> So I still think it's accurate to say the values of bit are true and false
>> since that implies the correct type while saying the values are 0 and 1
>> confuse the type bit with int. To illustrate
>> assert(typeid(typeof(1)) == typeid(bit));
>> fails.
> 
> That's correct. I guess one *should* say the "bit" is true and false. Like many others, I am more comfortable with using the alias "bool".
> 
>>>And when you for instance put a 2 into a bit, it gets the value of 1... (as does any non-zero integer you put into it. 0 is still 0, or "false")
>> 
>> I can't assign 2 to a variable of type bit. It says it can't convert int to bit. Do you mean cast(bit)2?
> 
> Sorry, yes - that is what I meant. Thus, bit is not an integer type ? (which is easy to believe if you just hear the term "bit" being used)
> 
> I still don't know what all the fuss about calling it "bit" is about. (why it wasn't named "bool" in the first place... probably the size ?)

Its a confusion between implementation and theory.

bit is a number value. Semantically speaking, it makes sense to do arithmetic on numbers, and it doesn't make sense to test the truth of a number.

bool is a truth value. Semantically speaking, it doesn't make sense to do arithmetic on truths, and does make sense to test the truth of a truth.

However, Walter has decided to *implement* bool as if it was the same as a bit. Which allows coders to do stupid things like ...

<code>
import std.stdio;
void main()
{
  int a;

  a = 2*true + false;

  bool b;
  b = 1;
  b++;

  bool c;
  c = cast(bit)2;
  c = cast(bool)-2;
  writefln("%s %s %s %s", a, b, b+1, c);
}
</code>

One would have thought that a smart compiler could have just said - "Hey! That doesn't make any sense. Do it properly."

The belief is that if bool is implmented as a bit, then the compiler can create some optimised machine code. What isn't so strongly believed, is that one can do that *in addition* to better compiler type checking.

> Oh well, that's been decided since long. Time to move on, for sure. I'll try not to mutter, when next newcomer to D wonders about this...

True, or should I say 1 ;-)

-- 
Derek
Melbourne, Australia
22/04/2005 9:31:51 AM