Mail Archives: djgpp/2001/10/21/14:10:24
----- Original Message -----
From: "Traveler" <traveler AT netti DOT fi>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp
To: <djgpp AT delorie DOT com>
Sent: Thursday, October 18, 2001 6:51 PM
Subject: Making C++ little easier to beginners...
> Little example...
>
> int x = 10,
> y = 10;
>
> if(x == 10 && x == 10) // Does this look scary or weird to you ?
> cout << "true\n";
> else
> cout << "false\n";
>
>
> wouldnīt this be nicer ?
>
> if(x EQUAL 10 AND y EQUAL 10)
> cout << "true\n";
> else
> cout << "false\n";
>
> Hereīs little helper...
>
> #define AND &
> #define COMPLEMENT ~
> #define EQUAL ==
> #define EQU EQUAL
> #define NOT !
> #define OR |
> #define XOR ^
>
> As you can see the things "AND" & "OR" defined here are "bit" operators
not "logical" operators.
> However, there really is no difference becourse you can use these two just
as easily in "if" statementīs as in bit manipulation.
>
> All calculations done in computer, from the simplest addition to the most
complex 3rd grade (or greater) root solving uses these operatorīs and their
compinations inside the microprocessor.
>
> "Traveler2001AD"
> traveler AT netti DOT fi
>
Hey maybe you should get this patented!
Experts might find your suggestions idiotic , but maybe beginners like
it , infact i think its ok ... but u see by hiding simple intricacies like
operators from beginners , you might be making them weaker , a lot of times
(at least at my school where we learn C++ in our ciriculum ) we have some
questions where we have to predict the result of an expression , which uses
all the basic operators that you changed to your liking using preprocessor
macros.
Remember its not a war b/w boolean and C++ ... its about rules , when the
syntax and semantic standards for a programming language are defined , they
are done so for the convenience of the programmers , i.e to make code much
more readable and easier to program. If you think you can embellish the
legibility then you are welcome , but you should remember that in such
course you are depriving the beginners you wish to help of the much needed
practice they can get on simple operators!
Enjoy !
- Raw text -