code reading dds

Code ReadingFAQ

What is the code appearing on the book's cover?

A list of comments marking code parts of dubious quality. You can read the full list of such comments appearing in the book's CD-ROM here.

How did you create Figure X; the Index; the code-cross references?

You can find answers in this description of the book's production process.

I have this really inscrutable piece of code. Since you are so good at reading code, can you please help me decypher it?

Unless I wrote, or I am supporting the code your are referring to, I do not have the resources to answer such questions. The book contains excellent advice on dealing with code that is difficult to understand, try to apply it.

What is the answer to exercise X?

Most exercises are quite open-ended and do not have one correct answer. Besides, the objective of the exercises it to do them on your own.

I think the book contains an error on page [...] .

Please first have a look on the errata page to see if this is a known and documented error. If it isn't, you might have found a new one. Please drop me a line with a short description of the error, the page number, and the book's printing number (shown on the bottom of the fourth page). If this is an error in the text I wrote, I will probably add it in the errata page with a reference to your name (unless you ask for your contribution to remain anonynous). Errors in the open source code examples also interest me, but do not go in the errata page; I might include a note in a subsequent edition.

Can I use the tricks I learn from reading the book's GPLed code at work?

The GNU General Public License is associated with the code's copyright. Copyright protects the expression of an idea, not the idea itsself. Thus, using a variable name appearing in GPLed code one has read could be problematic, but adopting a design used in GPLed code in new code one creates should be ok. In addition, none of the code appearing in the book is GPLed. I have used code licensed under BSD and similar licenses, to avoid problems with intepreting the GPL and its requirements.
Disclaimer: I am not a lawyer, and this is not legal advice.

How can I compile the code from the book's CD-ROM

The code in the book's CD-ROM is there to give you the full context of the more than 600 examples that point to it. Compiling the code was tricky for me in the cases I had to do it, and will probably will also be tricky for you, because systems move forward and render older versions incompatible with modern compilers, header files, tools, and libraries. The best option is to download a modern copy of the corresponding system, and follow the compilation and installation instructions that come with it.

What happened to the -1/2 on the last line of the binary search algorithm correctness proof?

More details of the question follow. In section 2.11 you show the correctness of the binary search algorithm. On page 59, just after the sentence ``When lim is decremented by one at Figure 2.12:5 we substitute lim + 1 in our invariant to obtain'', there are three equivalences, the last of which doesn't hold:

R ∈ [ base : base - (lim+1)/2 - 1 + lim + 1 ) ≡
R ∈ [ base : base + lim - (lim+1)/2 ) ≡
R ∈ [ base : base + lim/2 )

Answer: in integer arithmetic
1/2 = 0
and therefore it can be omitted. Jukka Salmi suggested to add an additional equivalence to make things clearer:

R ∈ [ base : base - (lim+1)/2 - 1 + lim + 1 ) ≡
R ∈ [ base : base + lim - (lim+1)/2 ) ≡
R ∈ [ base : base + lim/2 -1/2 ) ≡
R ∈ [ base : base + lim/2 )

My question is not answered here. What now?

See my personal FAQ list, and if that fails to answer your question send me an email with a concise description of your question. Keep in mind that I receive more than a hundred messages every day, so I may take some time to answer to your message.

Book homepage | Author homepage

Valid XHTML 1.0! Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 (C) Copyright 2000-2009 D. Spinellis. May be freely uploaded by WWW viewers and similar programs. All other rights reserved.
Last modified: 2009-01-02