[comp.lang.c] == vs. = a final word

edw@IUS1.CS.CMU.EDU (Eddie Wyatt) (03/25/88)

 I thought I would add a final observation on the issue of ==  vs. =
and associated bugs.  I've come to the conclusion that simularity of
== and = is not at fault.   Neither is the feature that both may
appear within the same context.   It is the combination of features
that really compose the problem, not the individual components.
Any redesign should be evaluated against this flaw.  

Again this is not a proposal to change C, just a discussion of a misfeature.

-- 

Eddie Wyatt 				e-mail: edw@ius1.cs.cmu.edu

llave@phoenix.Princeton.EDU (Rafael Llave) (04/01/88)

When I started programing in C -having programmed in
Fortran and Pascal , I made mistakes with the comparisons.

What I did is to include in my file "macros.h" -always included in
my programs -

#define EQ ==
#define LEQ <=

etc.

One of the advantages of C is that you do not
need to get tied by the grammar. K&R themselves
suggest 

#define BEGIN {
#define END }

for enthusiasts of the notation

gwyn@brl-smoke.ARPA (Doug Gwyn ) (04/01/88)

In article <2285@phoenix.Princeton.EDU> llave@phoenix.Princeton.EDU (Rafael Llave) writes:
>K&R themselves suggest 
>#define BEGIN {
>#define END }

I think you missed the sarcasm; this is not recommended practice.
The second edition should make this clearer.

ken@cs.rochester.edu (Ken Yap) (04/01/88)

Yeah, I saw a .h file that did:

#define		K	*1000

Of course the next time somebody used K as a variable...
A couple of us wasted 10 minutes figuring this out. Really stupid.

Other inanities included

#define		IS_EQUAL	==
#define		function

Of course, one day I compiled a graphics routine with:

	int	(*function)();

	Ken

PS: I like C. And Pascal, sometimes. And other languages. It's people
who have to make C look like the last language they learnt and never
get used to the new lingo that make life difficult.

ray@micomvax.UUCP (Ray Dunn) (04/13/88)

In article <2285@phoenix.Princeton.EDU> llave@phoenix.Princeton.EDU (Rafael Llave) writes:
>...
>#define EQ ==
>#define LEQ <=
>...
>K&R themselves suggest 
>#define BEGIN {
>#define END }
>...

And so once again we have come full circle in this discussion (:-) (:-)!

Sigh!

Now, as I was saying, my favourite colour is "red" (or was it "green"?  No,
I think it was "red").....

Ray Dunn.  ..{philabs,mnetor}!micomvax!ray