Re: Brian Kernighan, maybe I'm not worthy, maybe I'm scum



spinoza1111 said:

On Dec 31 2007, 10:00 pm, Richard Heathfield <r...@xxxxxxxxxxxxxxx>
wrote:
<snip>

Question 5 is broken. None of the specified types guarantees the
necessary precision for dealing with twenty decimal digits. The long
double type only guarantees ten. One could reasonably argue that any of
the integer types mentioned gives an adequate basis for developing a
bignum library that could give the required precision.

Bad flaw, I agree. Still, life's unfair. Do you suggest abandoning the
challenge or finding new tests? I can search for better tests if you
like.

Do what you like. I've already shown that you picked a lousy test, and that
a competent C++ programmer would have chosen a better one.

I'd say your analyses exhibit fairly good qualifications were it
not for your analysis of question 6, which I do not accept.

What you choose to accept or not accept is neither here nor there. The
rules of C++ are not defined by me or you but by ISO.

<snip>

You may be right. This question may be trash.

It is. It's complete bunk.

Still, to be fair to
all, we need to all accept these tests as final

No, we don't need to do any such thing. The test is broken. It is
inadequate for measuring knowledge of C++, let alone skill in using C++.

<snip>

Question 8 is broken. All of the suggested answers except A exhibit
undefined behviour, and answer A modifies the value of x. There is no
correct answer.

(A) x++;
(B) x += x--;
(C) x = x++;
(D) x = --x + 1;

The correct answer is D, and neither it nor any question exhibits
undefined behavior in C++, or in usable C compilers.

Wrong. See ISO/IEC 14882:1998 5(4): "Except where noted, the order of
evaluation of operands of individual operators and subexpressions of
individual expressions, and the order in which side effects take place, is
unspecified.53) Between the previous and next sequence point a scalar
object shall have its stored value modified at most once by the evaluation
of an expression. Furthermore, the prior value shall be accessed only to
determine the value to be stored. The requirements of this paragraph shall
be met for each allowable ordering of the subexpressions of a full
expression; otherwise the behavior is undefined."

Richard, am I missing something?

Yes - you are missing a basic understanding of C++.

Question 9 is trivial.

Question 10 fails to account for pointer comparison, but is otherwise
trivial.

In C and C++, pointers are integers and as such compareable

No, in neither C nor C++ are pointers integers. They can be converted to
integers, but this conversion is not guaranteed to be lossless.

<snip>

Question 14 is ambiguous - it depends on whether you consider 'between'
to be inclusive. I don't, so I might disagree with the marker over which
answer should be considered correct.

Question 14 does NOT depend on whether the English word "between" is
inclusive.

Yes, it does.

In ordinary speech it is used both ways!

That is why the question is ambiguous, which is what I said.

But the competing
answer uses an OR (hope you noticed)

No, in all honesty I missed that. Had I noticed, I would have said that
there was no answer that I could consider correct.

and the best answer is A. The
ONLY answer is the BEST answer.

Even if, by my lights, it's wrong? I don't think so.

<snip>

Question 22 is incorrect. sqrt is declared in <math.h> but only a
complete bozo would define it there.

If we MUST use terms like "bozo", only a complete bozo would use
"define" when he means use, dear Richard. The correct answer, I
believe, is #include. Do inform me why the question is "incorrect".

The question is incorrect because it claims that sqrt is defined in math.h,
which is false. Only a very broken implementation would put a definition
of the sqrt function in math.h. If it were not made static, only one
source file in the program would be able to include math.h! And if it were
made static (and I'm not certain whether that's legal in a conforming
implementation), it would in any case be unnecessarily bloating the
program by creating one instance of the function for each source file in
which the header is included.

<snip>

Question 29 has no correct answer. Arrays don't hold types. They *have*
types, but they are aggregate types that can store multiple *objects* of
a given type. If we agree that that's kinda what the guy meant only he
didn't say it very well, we must discount (A) as being incorrect
(because they can hold complicated types such as user-defined types). We
must also discount (B) because arrays can't hold function types
(although they /can/ hold function pointer types). And we must discount
(C) for the same reason as (B).

Gee, is a function a type?

No. A function *has* a type, and the type that it has is called a function
type.

Question 32 has no correct answer.

No, creating a struct is similar to creating a class.

That wasn't one of the available answers. They were:

(A) is similar to creating a class without member functions

But C++ structs can indeed have member functions, so this answer is wrong.

(B) requires the keyword static

This is not the case. C++ structs do not require the keyword static.

(C) requires the keyword public

This is not the case. C++ structs do not require the keyword public.

(D) is exactly like creating a class, except there must be at least one
member function.

This is not the case. C++ structs can have member functions, but do not
require them.

C sucked because

I do not find your opinion on C particularly valuable. It is now apparent
that your opinion on C++ isn't particularly valuable either.

<snip>

Excellent score, and thanks for your comments.

A better score would have been "did not compete", because the test was not
worth the time it took to do.

I think that IF you have used C++ professionally in the past for any
significant length of time, and scored only 4 points more than a
person who's only occasionally maintained C++, and who now only uses C
rarely, you might want to apologize at this time for the many comments
you have made about my professional qualifications.

You don't understand, do you? I Did Not Answer the questions that had no
correct answer. There were many of these, so the scores are meaningless.

You may see some value in giving incorrect answers just to please a test
marker, but I don't.

When I posted in
2003, you took a vanishingly small number of data points and blew them
out of proportion.

You have now increased the number of data points available to me. My
analysis looks spot on, and I see no reason to change it - the new data
confirms it.

I'm not going to do that with the questions you got wrong.

Let's do a little test, with just one question.

1. In sociology, "alienation" means:
(a) a rabbit
(b) a ball-point pen
(c) seventeen
(d) the Aegean Sea

What would you answer? And how much weight would you give the results? If
you didn't get the same answer as the tester, what do you think that would
say about your knowledge of sociology?

Clearly, the test is broken and stupid, and no reliance can be placed upon
its results. The same applies to that C++ test.

<snip>

I ask you in future to emulate my style in my comment on your comment
on question 6. I believe that the prefix and postfix increment and
decrement operators have, or damned well better have, an order of
execution relative to the precedence of assignment.

Your beliefs do not affect the reality of C++ language rules.

<snip>

But, you're not an idiot.

I wish I could say the same about you.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: MFC Newbie Question - Getting pointer to View Class from theApp
    ... I want a pointer to my view class to call some ... member functions. ... class CTest2View: public CEditView ...
    (microsoft.public.vc.mfc)
  • Re: Coding style survey
    ... snip ... ... I shall continue to religiously avoid returning structs ... I would simply make 'hshstatus' return a pointer ... > const struct hshstats status; ...
    (comp.lang.c)
  • Re: useless casts
    ... >impression that it held for all initial members of any two structs, ... >long as all the intervening initial members are of the same type. ... A pointer to a struct, if suitably converted, may serve as ...
    (comp.lang.c)
  • Re: structure and constant memebers
    ... > own development practices are so strongly predisposed to never ... >> No one should object to the cast as such, which is clearly a pointer ... but for reasons that are ...
    (comp.lang.c)
  • Re: Virtual Machine implementation problem, Please help me to spot the bug
    ... developing it on Windows I don't know if there's ... mingw uses the Windows libraries, and the Windows equivalent to the ... Note that in this, similar, case, you got it right: you pass a pointer ...
    (comp.lang.c)