Article View: comp.lang.misc
Article #6116Re: colon-equal vs equal
From: Ray Dunn
Date: Fri, 06 Jan 1989 18:05
Date: Fri, 06 Jan 1989 18:05
44 lines
2682 bytes
2682 bytes
In article <3290002@hpctdls.HP.COM>, rbk@hpctdls.HP.COM (Richard Katz) writes:
> 'if ( i := 10 )' will produce a syntax error in Pascal while
> 'if ( i = 10 )' will produce an assignment in C, usually not
> intended. FORTRAN uses .EQ. to make sure that there is no mixup
In article <2567@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
>This has nothing to do with :=/= versus =/==. This has to do with C being an
>expression-based language and Pascal being a statement-based language.
Certainly the Pascal *compiler* picks up the error because Pascal is
statement based, however the compiler is hardly ever called upon to flag
that error, because with :=/= programmers rarely *make* the error.
In 'C' the problem arises both because it is expression based, allowing the
"if (assignment-expression)" construct, *and* because the assignment
operator is an overworked symbol which in many programming languages *and
other environments* implies equality.
>... If you want to flame a language, try
>BASIC ("if a = b then a = c"... the first is a comparison, the second an
>assignment).
The interesting thing about this, contrary to the implication, is that it is
neither ambiguous nor prone to create undetected errors. The multiple
meanings of "=" are nicely distinguishable by context, even though using the
same symbol for assignment and equality is dubious from a conceptual point
of view.
The =/== problem is not one of context dependancy nor of symbol over-use, it
is one of *lack* of context dependancy which is not necessarily a bad thing
in itself, and the "related" ambiguity of "=".
If you look at 'C' and its use of =/== in a totally introverted fashion,
then there *is* no problem.
It is only because of the use of "=" in the world outside 'C' (and not only
in the context of programming languages) that it becomes a problem in 'C'
that "=" in the context of "if" means assignment rather than equality.
--
Ray Dunn. | UUCP: ..!philabs!micomvax!ray
Philips Electronics Ltd. | TEL : (514) 744-8200 Ext: 2347
600 Dr Frederik Philips Blvd | FAX : (514) 744-6455
St Laurent. Quebec. H4M 2S9 | TLX : 05-824090
Technical Details
Message-ID:
<1600@micomvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ames!oliveb!pyramid!prls!philabs!micomvax!rayReferences:
<3300001@uxg.cso.uiuc.edu> <3290002@hpctdls.HP.COM> <2567@ficc.uu.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ames!oliveb!pyramid!prls!philabs!micomvax!ray From: ray@micomvax.UUCP (Ray Dunn) Newsgroups: comp.lang.misc Subject: Re: colon-equal vs equal Message-ID: <1600@micomvax.UUCP> Date: 6 Jan 89 18:05:24 GMT References: <3300001@uxg.cso.uiuc.edu> <3290002@hpctdls.HP.COM> <2567@ficc.uu.net> Reply-To: ray@micomvax.UUCP (Ray Dunn) Organization: Philips Electronics Ltd. (TDS - Montreal) St. Laurent QC, Canada Lines: 44