?

Log in

No account? Create an account
Lindsey Kuper [entries|archive|friends|userinfo]
Lindsey Kuper

[ website | composition.al ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

A textbook example [Feb. 22nd, 2004|10:37 am]
Lindsey Kuper

Bad and wrong.

From page 151 of Concepts in Programming Languages by John C. Mitchell:

For example, consider the following two expressions:

3 + 2
3.0 + 2.0

Here is how the compiler will produce code for evaluating each expression:

3 + 2: The parsing phase of the compiler will build the parse tree of this expression, and the type-checking phase will compute a type for each symbol. Because the type-checking phase will determine that + must have type int * int -> int, the code-generation phase of the compiler will produce machine instructions that perform integer addition.

3.0 + 2.0: The parsing phase of the compiler will build the parse tree of this expression, and the type-checking phase will compute a type for each symbol. Because the type-checking phase will determine that + must have type real * real -> real, the code-generation phase of the compiler will produce machine instructions that perform integer addition.

Okay, if you're going to insult our intelligence by writing the same thing twice, at least have the decency to correct "integer" to "real" in that last sentence. Not like that would disguise the fact that you copied and pasted, but at least then it'd be, oh, I don't know, not completely incorrect?

And the kicker, of course, is that this is from the section of the book about polymorphism and overloading, directly following your little rant about how the C++ implementation of parametric polymorphism "requires more effort at link time and produces a larger code, as instantiating a template several times will result in several copies of the code". Gosh, it sounds perfect for you.

LinkReply

Comments:
[User Picture]From: underwhelm
2004-02-22 10:10 am (UTC)
Are you kidding? That's what second (and third, and fourth...) editions are for!

Also: you'be been blogspammed! LJ should go back to the code system.
(Reply) (Thread)
[User Picture]From: lindseykuper
2004-02-22 12:56 pm (UTC)

Re:

Yeah, it's a dumb typo that'll probably be corrected in the next edition (and this is indeed the first). But the book's so full of silly typos, and this one was so ironic, given the context, that I just couldn't take it anymore. =)
(Reply) (Parent) (Thread)
[User Picture]From: lindseykuper
2004-02-22 12:58 pm (UTC)

Re:

Oh, and that guy still could've posted anonymously while there were invite codes.
(Reply) (Parent) (Thread)
[User Picture]From: underwhelm
2004-02-23 02:10 pm (UTC)

Re:

Yeah, I realized that after I posted.

But I still feel that way, so I left it thus.
(Reply) (Parent) (Thread)
[User Picture]From: gelishan
2004-02-25 08:07 pm (UTC)
LINDSAY!

Hi there. *adds*
(Reply) (Thread)
[User Picture]From: gelishan
2004-02-25 08:11 pm (UTC)
...I have a friend named Lindsay, whose name I'm apparently used to typing. I know how to spell your name. HONESTLY.
(Reply) (Parent) (Thread)
[User Picture]From: lindseykuper
2004-02-25 10:46 pm (UTC)
Heh -- that's okay. One of my good friends still consistently misspells it. At least he's consistent. =)
(Reply) (Parent) (Thread)