Re: Why multiplication not allowed?

From: Lew Pitcher (Lew.Pitcher_at_td.com)
Date: 01/07/04


Date: Wed, 07 Jan 2004 09:14:35 -0500

Sean Kenwrick wrote:
[snip]
> 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.

ISTR an article by one of the original C developers (Dennis Ritchie or
perhap PJ Plauger) commenting on the /very/ early syntax of C. Specifically,
the article said that the syntax

   i =+ j;

had been considered as a way to express

   i = i + j;

but was ultimately rejected because it was ambigious, and could be confused with

   i = j;

If I read http://cm.bell-labs.com/cm/cs/who/dmr/chist.html correctly, it
looks like this ambigious syntax was adopted from B into the earliest of C
compilers, but later dropped (in 1976) before the adoption of "K&R C".

[snip]

-- 
Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed here are my own, not my employer's)


Relevant Pages

  • Re: My view on this "Is blah an assembler"
    ... syntax, which could be used as an alternate to the default Intel ... parsing conflict with the label definition syntax, though, as ... The 'type recording' comes ...
    (alt.lang.asm)
  • Re: How do I create a function in my library for passing user callback function
    ... <snip lots> ... You must be aware that is this not the normal syntax. ... Again, that is up to you, but in my editor copying the prototype is ...
    (comp.lang.c)
  • Re: Javascript: string detection
    ... this script doesn' work, probably, because of the wrong syntax. ... A complete syntax check is better left to the server where existing code is more readily available and not a burden on the client. ... Be aware that even the regular expression above is restrictive as it won't accept literal IPv6 addresses, those that contain display names, or comments in some locations. ...
    (comp.lang.javascript)
  • Re: newbie SP question
    ... I also used CURRENT_TIMESTAMP (ANSI-standard SQL syntax) instead of your ... COMMIT TRANSACTION ... (Second note: with column names including category_1 through 5 and their ...
    (microsoft.public.sqlserver.mseq)
  • Re: Why multiplication not allowed?
    ... >> questions the interviewer asked me was to tell him what was wrong with the ... >> Afterwards I wondered whether this might have been some kind of syntax left ... AFAIK they were dropped when ISO ... Not many years ago, I used a compiler that allowed the ...
    (comp.lang.c)