Re: Why multiplication not allowed?

From: Keith Thompson (kst-u_at_mib.org)
Date: 01/07/04


Date: Wed, 07 Jan 2004 21:39:10 GMT

Joona I Palaste <palaste@cc.helsinki.fi> writes:
> Sean Kenwrick <skenwrick@hotmail.com> scribbled the following:
> > But I think the reason I didn't get the job was because one of the other
> > questions the interviewer asked me was to tell him what was wrong with the
> > following statement:
>
> > i=+i;
>
> > I said that there was nothing wrong with it, but the interviewer claimed
> > that it was an ambiguous statement because it could mean adding i to itselt
> > or setting i to +i. I got into an argument with him saying that he must
> > be confused with i+=i; but he was adament he was right and got annoyed that
> > I was disagreeing wih him.
>
> > Afterwards I wondered whether this might have been some kind of syntax left
> > over from a very early incarnation of C which was subsequently dropped.
> > Perhaps the members of this group could enlighten me about this since I
> > think that this guy was just a complete idiot.
>
> Yes, this is an obsolete feature of C. =+ and =- originally meant the
> same as += and -=. Whoever designed them that way must have been
> drinking something really strong. AFAIK they were dropped when ISO
> standardised C.
> That the interviewer still clung to the obsolete meanings of those
> operators makes me feel that he wasn't the proper person to interview
> you about C.

The =+ syntax was dropped long before ISO C; it had vanished by the
time K&R1 was published.

Not many years ago, I used a compiler (VAXC, I think) that allowed the
old =+ syntax, but I think it at least issued a warning about it. (It
also helpfully "corrected" the unrecognized "signed" keyword to
"unsigned".) The oldest C compiler I now have access to (circa 1988)
just treats =+ as a syntax error.

What's really wrong with the statement is that it lacks whitespace and
doesn't do anything useful.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"


Relevant Pages

  • Re: Why multiplication not allowed?
    ... > questions the interviewer asked me was to tell him what was wrong with the ... perhap PJ Plauger) commenting on the /very/ early syntax of C. ... looks like this ambigious syntax was adopted from B into the earliest of C ...
    (comp.lang.c)
  • Re: Tcl Switch case
    ... My thesis is that there could be a good reason to change the syntax of ... a command, and one reason is to align with what the byte compiler ... bug has persisted for 15 years, but has never kept anyone from writing ...
    (comp.lang.tcl)
  • Re: Handling error/status messages by interface to C++ programs
    ... about how to design a compiler, please tell me where I can find ... exceptions for managing the error detection is rather a bad idea. ... I have to say I have seen a simple example of an object-oriented parser design in some book (unfortunately I forgot ... It would trigger user notification and do recover housekeeping like reseting the current syntax row's token stack because one wants to continue parsing and detect any other errors w/o aborting. ...
    (comp.object)
  • Re: Syntax (was: Perfrom Thru
    ... "This statement has violated the limits of this compiler" ... these are syntax violations in the Standard's definition of them. ... > whether the problem is a compiler limitation or it is a syntax error, ... >> Then not "source violates the SYNTAX rules of the Standard" ...
    (comp.lang.cobol)
  • Re: Compiler quality
    ... compilers should be able to be 100% tested for syntax bugs by limiting ... be detected outside of the syntax portion of the compiler. ... language rules provide enough testing for the syntax proper. ... selection of a component using the "current instance" of a protected ...
    (comp.lang.ada)