Precedent for use of =

guy at sun.UUCP guy at sun.UUCP
Mon Jul 14 05:49:36 AEST 1986


> > If your compiler can't generate equally efficient code for
> > 
> > 	a = b;
> > 	if (a != 0)
> > 
> > and
> > 
> > 	if ((a = b) != 0)
> > 
> > on any machine other than an incredibly weird one, then your compiler
> > needs to be improved.
> 
> Ideally, degrees of optimization should be available,

Yeah, they should, but so what?  Why is this relevant to the previous
comment?  It doesn't say "if your compiler doesn't always generate", it says
"if your compiler *can't* generate".  The claim that constructs like

	if ((a = b) != 0)

are necessary because they generate more efficient code than

	a = b;
	if (a != 0)

is bogus; compilers *can* be made to generate equally efficient code for
both.  The fact that you can write things in the first style should *not* be
used as an excuse for compiler writers not to do optimization "because the
human will do it for you".
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.lang.c mailing list