🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1431

Re: := versus ==

#1431
From: Thomas Truscott
Date: Fri, 03 Aug 1990 14:07
30 lines
1374 bytes
> >   a == b is for comparison. Its value is 1 if they're equal, 0 if not.
> >   a := b is for assignment. It sets a to b and has value a.
> >   a = b is for assignment. It sets a to b and has no value.
> 
> Good idea. PL/M ... does something like this ...


I like the Q and PL/M features, but they don't stop me from typing:

	a == b + 1;	/* OOPS, I mean't to assign to a */
or
	if (a := b) ..	/* OOPS, I only wanted to compare them */
not to mention
	a = b++ * b++;


What we *really* need are compilers that issue warnings such as:

test.c: line 7: result of comparison unused!

test.c: line 8: assignment result used in boolean context,
	did you mean ((a := b) != 0), or (a == b)?

test.c: line 9: b evaluation order undefined

If our compilers did that there would be much
less debate about = and == and := in the C language.
And fewer frustrated programmers.

	Tom Truscott
Technical Details
Message-ID: <3989@rtifs1.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!usc!cs.utexas.edu!rutgers!mcnc!rti!trt
References: <1990Jul30.143530.24295@phri.nyu.edu> <25684@cs.yale.edu> <7H+4AM6@xds13.ferranti.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!usc!cs.utexas.edu!rutgers!mcnc!rti!trt
From: trt@rti.rti.org (Thomas Truscott)
Newsgroups: comp.lang.misc
Subject: Re: := versus ==
Summary: ":=" is nice, but a hand-holding compiler is even nicer
Message-ID: <3989@rtifs1.UUCP>
Date: 3 Aug 90 14:07:27 GMT
References: <1990Jul30.143530.24295@phri.nyu.edu> <25684@cs.yale.edu> <7H+4AM6@xds13.ferranti.com>
Organization: Research Triangle Institute, RTP, NC
Lines: 30