Xref: utzoo comp.lang.c:31793 alt.lang.cfutures:83 Path: utzoo!utgpu!cs.utexas.edu!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c,alt.lang.cfutures Subject: Re: Assignment in test: OK? Message-ID: <28433:Sep1221:22:4890@kramden.acf.nyu.edu> Date: 12 Sep 90 21:22:48 GMT References: <928@hls0.hls.oz> <18326@ultima.socs.uts.edu.au> Followup-To: alt.lang.cfutures Organization: IR Lines: 17 In article <18326@ultima.socs.uts.edu.au> jeremy@sinope.socs.uts.edu.au (Jeremy Fitzhardinge) writes: > >> BTW, if I ever write a new C-like language, ":=" will be the assignment > >> operator, "==" the comparison operator, and "=" totally invalid! Although > If you are going to prevent assignment in a conditional, you are preventing > it from being an expression. This stops things like "a=b=c=0;" from falling > out elegantly. Q has == for comparison, = for assignment with no value, and := for assignment with a value. (Among others.) So ``a = b'' still works, ``if (a = b)'' is illegal, and the compiler can check all statements for unused values. The only correct code that has to be rewritten is ``a = b = c = d'' (as ``a = b := c := d'') and a proper ``if (a = b)'' (as ``if (a := b)''). Followups to alt.lang.cfutures. ---Dan