May 27, 2005
Come, come... let's not go insulting.  Everyone's friends here :).  As they say in various other places - let's attack *positions* not *people*.

Anyway, I wouldn't ever do this:

writef(true);

Because its effect is undefined in my mind; sure, I would expect 1, but it doesn't make logical sense.  I would do this, instead:

writef(cast(int) true);

Or much more likely:

writef(true ? "1" : "0");

-[Unknown]


> "Sam" <Sam_member@pathlink.com> wrote in message news:d75itd$8nt$1@digitaldaemon.com...
> 
>>Except it wasn't with STL...  I don't remember if it was with VB6, MFC or java,
>>but one of those languages screwed me my outputing to a file the string "true"
>>and "false", INSTEAD of 1 or 0.
>>Wish I could remember which language this was in...
> 
> 
> MFC is not a language, and std::cout << true; is quite obviously C++ code..
> 
> 
>>Like most people I never test my code
> 
> 
> You mean _unlike_ most people?
> 
> Something tells me you're not a programmer by trade.  That, or you aren't a very good one. 
> 
> 
May 27, 2005
Sam wrote:
> I read an argument about the 'bit' type.  It seems people can do this:
> 
> int i = true * 8; // yields 8
> i = false * 8; // yields 0 ?

If people are doing this, they must have good reasons.
I don't think these keywords are causing any problems here.
Besides, your proposed method is truly a verbose eyesore to me.

> 
> Static operators or methods eliminate this problem!  Get rid of the 'true' and
> 'false' keywords!!
> 
> I propose:
> 
> bit a;
> bit.settrue(a);
> bit b;
> bit.setfalse(b);
> a = b || !b;
> 
> There are probably better names for these 2 methods...  'setto1' and 'setto0'?
> Doing so eliminates the need for 'true' and 'false' keywords!
> 
> I would like to see the following keywords ELIMINATED, as they are just a source
> for exceptions:
> 
> null
> false
> true
> 
> Sam-
> sam987883@yahoo.com
May 27, 2005
> Something tells me you're not a programmer by trade.  That, or you aren't a very good one. 

Indeed.
May 27, 2005
>I think it's a mistake in C# and ANY LANGUAGE that have kept 'true' and 'false'!
>
>I don't mean to sound like a Boolean extremist, but how often do these 2 keywords get used??  Honestly????

I can only speek for myself, but I use them often.

>Basically, true and false have only 2 functions, and you only ever need only one of them!!!  Because false = !true

right and 2 = 1+1 so let's get rid of all literals beside 0 and 1. Perhaps we should remove 0 as well, as it can be expressed as 1-1.

>One function is testing a value:
>
>if(b == true)
>
>BUT, you can just do this:
>
>if(b)
>
>Second is assignment:
>
>b = true;
>b = !true;
>
>BUT, you can do this instead:
>
>b = 1;
>b = 0;
>
>1 and 0 are already part of almost every programming language!
>
>Why keep keywords that are not needed?

Instead of

# while (someCondition) {
#    ...
# }

you can write

# for (;someCondition;) {
#    ...
# }

so why should we keep those stupid keywords like while and do? Or look at this:

# lable: if (someCondition) {
#    ...
#    goto lable;
# }

So we can remove for as well.

>In C++ we didn't have a 'null' keyword, and we never needed one!

It will get one, but it's called nullptr.

# void foo (int x);
# void foo (void * x);
#
# foo (0);  // :)

>The less keywords a language has, the simpler it bacomes and the easier it is to learn.

Nope. A language with more keywords is often much easier. E.g. D has a foreach keyword which often makes iteration much simpler than in C++.


>Exceptions from true and false??  Maybe!  What does this do:
>
>cout << true << false; // ?

How often have you written this code? If you aren't sure what your code does, don't write it. You could use

# cout << true;
# cout << false;

to get sure.

-- Matthias Becker


May 27, 2005
>I did something like:
>
>std::cout << true;
>
>Except it wasn't with STL...  I don't remember if it was with VB6, MFC or java, but one of those languages screwed me my outputing to a file the string "true" and "false", INSTEAD of 1 or 0.

The iostram isn't part of the STL!

And you got that output in that language/library because true and false have the type bool/boolean/... and not int/integer/... . If you want to write a 0 or a 1 than just do that. Don't expect the language to do some mistirious things if you aren't absolutly sure it will.

BTW, ever used std::boolalpha ?

>Like most people I never test my code (that's extra time I could be using to write more code or surfing the web) and I got burned!  Bad!!

LOL! You never test your code? Yre you sure you've ever written a program that actually works?



May 27, 2005
>I read an argument about the 'bit' type.  It seems people can do this:
>
>int i = true * 8; // yields 8
>i = false * 8; // yields 0 ?

Why should anybody ever write code like this? The only reason I can see is an obfuscation-contest.

>Static operators or methods eliminate this problem!  Get rid of the 'true' and 'false' keywords!!
>
>I propose:
>
>bit a;
>bit.settrue(a);
>bit b;
>bit.setfalse(b);
>a = b || !b;
>
>There are probably better names for these 2 methods...  'setto1' and 'setto0'? Doing so eliminates the need for 'true' and 'false' keywords!

and you can read your code above much faster than:

# bool a = true;
# bool b = false;
# a = b || !b;



May 27, 2005
Sam wrote:
> I think it's a mistake in C# and ANY LANGUAGE that have kept 'true' and 'false'!
> 
> I don't mean to sound like a Boolean extremist, but how often do these 2
> keywords get used??  Honestly????

Any half decent programmer would use them ALOT.
I Do.

btw, it's really scary that you don't test your code.

> Basically, true and false have only 2 functions, and you only ever need only one
> of them!!!  Because false = !true
> 
> One function is testing a value:
> 
> if(b == true)
Dude .. this is one of the most important functions in programming: without it, there wouldn't be any programs.

> BUT, you can just do this:
> 
> if(b)
That's because at the low level, booleans are simply a test against zero.
But that's at the low level.
The purpose of programming languages is to bring programming to higher levels.

> Second is assignment:
> 
> b = true;
> b = !true;
> 
> BUT, you can do this instead:
> 
> b = 1;
> b = 0;
you can also write
char b[] = "Hello world"
as
char b[] = { 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 }

except that the first is logically sound, while the second is meaningless to humans.
Both are the same to computers, though.

> In C++ we didn't have a 'null' keyword, and we never needed one!
we actually do ... as has been mentioned before
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1601.pdf
1 2
Next ›   Last »