[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: not enough real programmers?
jon@axtell.obvious.demon.co.uk (Jon Axtell) writes:
> When I was interviewing people (and I have interviewed over 100
> engineers) I made up a simple questionaire which was deliberately
> open-ended. It was a more look at this sample of code, and discuss.
> It's aim was to get the engineer to talk about the code sample and
> from their views I got a very good impression of what kind of
> programmer they were, and also if they /really/ knew C.
>
> The questions were like...
> 1) if (toupper( *ch++)) == 'A') then ch++
> 1) side-effect from ch++ in a macro which is evaluated twice
But in Standard C, toupper() is defined as a function. If it's also
implemented as a macro (it must always be implemented as a function,
so that users can use it via a function pointer), the macro must not
have side effects. Back in the dark ages, it couldn't be used safely.
You also had to ensure that islower(arg) was true, otherwise you might
get surprising results.
Another fault with this example is the PASCAL-ization of C with the
preprocessor to get the 'then' keyword. :-)
--jtc
--
J.T. Conklin
Redback Networks, Inc.