By Developers, For Developers

Historical errata for Seven Languages in Seven Weeks

PDF PgPaper PgTypeDescriptionFixed onComments
59TYPO

the last code line of the page should read:
> list("find my car", "find Continuum Transfunctioner","Get girlfriend a present") instead of > list(“find my car”, “find Continuum Transfunctioner”, “Find a present”)

2010-04-03
16TYPO

Mac OS X should be spelled with a capital X. This seems to be a recurrent typo throughout the book.

2010-04-03
27ERROR

The code examples with the logical or operator mistakenly use exclamation marks (!) instead of pipe characters (|) thus generating unexpected errors. The correct versions should be:

true || this_will_not_cause_an_error

and

true | this_will_cause_an_error

2010-04-03
63ERROR

In the book: “That’s simple enough. Make a note: 0 is true as in Ruby, not false as in Java, C, or C#.”
That’s true of C, but in Java 0 is not false, because in Java 0 is not a boolean but an integer. As far as I can tell the same happens with C#.
As an example, the next Java code would not compile:
int num = 0;
if(!num){
System.out.prinltn(“0 is false”);
}

2010-04-03
61TYPO

Io> toDos append(“Get girlfriend a present”) > list("find my car", "find Continuum Transfunctioner", "Find a present") Should be: Io> toDos append("Get girlfriend a present") > list(“find my car”, “find Continuum Transfunctioner”, “Get girlfriend a present”)
Unless Io is able to “simplify” “Get girlfriend a present” to “Find a present”. ;)

2010-04-03
65TYPO

I believe that:

What is the difference between =:= and ::=? When would you use each one?

should be

What is the difference between := and ::=? When would you use each one?

2010-04-03
57SUGGEST

By reading the previous page and the BNF grammar I CAN’T really tell that receivers go on the left an messages on the right. In fact, the construction receiver message does not appear in the BNF grammar.
I would explain that the construction message message (allowed by the grammar) means sending the second message to the first message object. Or even rewrite the grammar as:
exp ::= {messages terminator}
messages ::= {message}
…
That way there is a specific element in the grammar (I called it messages, a better name can be found) that represent the receiver message chain.
P.S. I know the grammar is that of the iolanguage.com as is. I found that one a bit difficult to understand for newbies as well.

2010-04-03
27ERROR

It looks like the !! and ! operators in the Ruby conditional examples should have been || and | (double pipe and pipe):

>> true !! this_will_not_cause_an_error
SyntaxError: compile error
(irb):61: syntax error, unexpected ‘!’, expecting $end
true !! this_will_not_cause_an_error
^
from (irb):61

2010-04-03
8TYPO

Seems like “spits out” may have been the intended phrase but just because I’ve never heard “splits out” (i.e. with the ‘L’) doesn’t mean it’s wrong.

“… it is rather a matter of getting the semicolons and
commas in the right places and understanding the weird error messages
that the system splits out when you make an error.”

2010-04-03
38TYPO

method is called ‘to_file’ in text, and called ‘to_f’ in example code

2010-04-03
40TYPO

a.sort called twice and ‘a’ assigned twice. it wasn’t clear to me if this was an oversight or meant to demonstrate something. It doesn’t seem important to show that a.any? did not change the state of ‘a’

a.sort
[1, 3, 4, 5]
a = [5, 3, 4, 1]
[5, 3, 4, 1]
a.sort
[1, 3, 4, 5]

2010-04-03
9TYPO

“Thus is is with programming.” Should only have 1 is

2010-04-03
14TYPO

“…I picked are not necessarily the best, but each each one is unique…” 2 “each”

2010-04-03
12TYPO

Two ‘and’ in the sentence: “I struck JavaScript because it
was too popular and and replaced it with…”

2010-04-03
59TYPO

From your example:

Io> toDos := list(“find my car”, “find Continuum Transfunctioner”)
> list("find my car", "find Continuum Transfunctioner") Io> toDos size '> 2
Io> toDos append(“Get girlfriend a present”)
==> list(“find my car”, “find Continuum Transfunctioner”, “Find a present”)

adding “Get girlfriend a present” results in the list having “Find a present” added to it???

2010-04-03
24TYPO

‘language’ should be ‘languages’: “…but many
of those language have procedural elements too.”

2010-04-03
24TYPO

2 ‘of’: “…method returns an array of of methods..”

2010-04-03
65TYPO

Under the “Day 1 self study” heading, in the “Find:” section, the first item reads “Some Io examples problems”; I believe the word “examples” should not be pluralized, e.g. “Some Io example problems”.

2010-04-03
61OK

On the Win32 build Io-2008-01-07 when I run “true and 0” (true and zero) I get 0 (i.e. zero) as the result.

2010-04-20won't support other platforms... see above.
60OK

When running in Win32 build Io-2008-01-07 I don’t see “asObject” in the list when I type “Map proto” and when I create a Map and fill a map I get the following when I try to run “asObject”:

Exception: Map does not respond to ‘asObject’
————-
Map asObject Command Line 1

My code is:

Io> maap = Map clone
==> Map_0x518370:

Io> maap asObject

Exception: Map does not respond to ‘asObject’
————-
Map asObject Command Line 1

Io> maap atPut(“a”,1)
==> Map_0x518370:

Io> maap atPut(“b”,2)
==> Map_0x518370:

Io> maap asObject

Exception: Map does not respond to ‘asObject’
————-
Map asObject Command Line 1

Io> maap asobject

Exception: Map does not respond to ‘asobject’
————-
Map asobject Command Line 1

2010-04-20Sorry... I really can't support other platforms. If I just took the top 4 platforms, I'd be going through examples in 28 language/platform combinations. Throw in version numbers for the languages, and it's just too much.
8TYPO

first line that is repeated twice “Let’s assume that that you’ve actually managed the difficult task”

2010-04-03
9TYPO

“This make the the difference” make -> makes

2010-04-03
25TYPO

Syntax hilighting/code colouring wrong: the “puts” line after the unless/else. (10th line of typed code in that segment)

2010-04-20
101TYPO

Docbook markup visible for some reason (3/4 down):

2010-04-03
68ERROR

Io> postOffice := Object clone
==> IpostOffice_0x10059c738:
type\t= “IpostOffice”

should be:

Io> postOffice := Object clone
==> Object_0x100595860:

2010-04-03
30ERROR

“Unlike Java and C. you don’t have to build a whole class to define a function.”
You don’t have to build a class to define a function in C.

2010-04-03
63TYPO

In this sentence: “Steve Dekorte: In 2002, my friend Dru Nelson wrote a language called
Cel (inspired by Self) and was asking for feedback on it’s implementation.”

There should be no apostrophe in “its” as it’s a possessive: “Steve Dekorte: In 2002, my friend Dru Nelson wrote a language called
Cel (inspired by Self) and was asking for feedback on its implementation.”

2010-04-03
68SUGGEST

First paragraph of the “messages” section says: “You
briefly saw reflection through call in the unless example.” I can’t find the “unless” example: has it been omitted?

In fact, reflection is an area that I find badly explained in the book and on the Io web site so a bit more details would be very much appreciated.

2010-04-03
76TYPO

Four lines from bottom: “If the message is anything else, RowBuilder forwards that back to Builder, and we’re done.” but there is no RowBuilder prototype defined in the code.

2010-04-03
78TYPO

Top of page: “Fezzik and Vizzini are independent objects with coroutines. fezzik and vizzini are instances of these.”

There are no objects Fezzik and Vizzini, just two instances fezzik and vizzini, with coroutines talk and rhyme.

2010-04-03
78TYPO

Remove redundant “fire” in: “We fire fire asynchronous pitch and catch methods.”

2010-04-03
78TYPO

“We fire fire asynchronous pitch and catch methods.” The methods are called “talk” and “rhyme”, not “pitch” and “catch”.

2010-04-03
81TYPO

Last exercise:

book({“author”: “Tate”}…“) would print >p author=”tate“”<:

should read:

book({“author”: “Tate”}…) would print

(incorrect angle brackets, extraneous double quote and colon characters)

2010-04-03
90TYPO

Example in the middle of the page:

| ?- food_type(sausage, sweet).

This question makes no sense, presumably the one that was intended is:

| ?- food_flavor(sausage, sweet).

2010-04-03
106TYPO

Bottom of the page, concatenate is misspelt concatinate throughout the code example, including at the top of page 107.

2010-04-03
112TYPO

Second paragraph:

Gnu Prolog has a built-in predicate to express possible values, called fd_domainfd_domain(List, LowerBound, UpperBound).

The extra fd_domain should be removed.

2010-04-03
117SUGGEST

A couple of simple diagrams to show that all queens that have the same value for col-row are on the same northwest-southeast diagonal and that all queens that have the same value for col+row are on the same southwest-northeast diagonal would help in understanding the explanations. The simplest would probably be an 8x8 board with numbered columns and rows and greyed out diagonals with actual values for col-row and col+row.

2010-06-08I will probably fix this one in a later edition.
129SUGGEST

This sentence is misleading: “In Java, some strings were literals, and some were objects.” At the end of the day, even when declared as a literal, all Java strings are objects and immutable. Furthermore, the discussion above that sentence is about numbers so talking about Java strings only confuses the reader.

A better comparison would be to say that in Java, all numbers have a primitive and and object version (int vs Integer), that led hundreds of Java programmers to despair when they had to convert from one to the other and prompted Sun in adding autoboxing in J2SE 5.0.

2010-04-03
130TYPO

First paragraph, last line, “string” should be capitalised in “java.lang.string”.

2010-04-03
131ERROR

This sentence is incorrect: “In Java, 0 was false. In both languages, nil evaluated to false.”

In Java, both if(0) and if(null) will generate a compilation error, just like Scala. Attempting to cast 0 or null to boolean won’t work either and will generate the same compilation error.

You can verify this by trying to compile this short Java program:

public class Zero {
public static void main(String args[]) {
if(0) {
System.out.println(“true”);
} else {
System.out.println(“false”);
}
}
}

2010-04-03
131ERROR

First paragraph, second line:

var is immutable; val is not.

This is specified the wrong way round: var declares a mutable variable while val declares an immutable value.

2010-04-03
132TYPO

Last paragraph, first sentence: “So my thinking of static typing was shaped by my the Java wars.” Either remove the word “my” or the word “the” in front of the word Java.

2010-04-03
135ERROR

First paragraph, first sentence:“It’s mildly surprising that the range by 5 included 10, but the range by
1 did not.”

This is because the range by 5 used the “to” keyword while the range by 1 used the “until” keyword. The top boundary is included with “to” and excluded with “until”. You can try that for yourself by running:

scala> (0 to 10)
res6: Range.Inclusive = Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> (0 until 10)
res7: Range = Range(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

So the sentence above should be re-worded to specify the difference between the “to” and “until” keywords.

2010-04-03
137ERROR

Last paragraph, second setence: “Unlike Java code, you can execute arbitrary code, such as the println statement.” I’m not sure what you mean by this statement: you can execute arbitrary code in a Java constructor too. The only constraint is that if you call super(), it has to be the first statement in the constructor but otherwise I am not aware of any arbitrary code that you can’t run.

2010-04-03
142TYPO

Paragraph before last, second sentence: “Instead, Scala uses a concept called companion classes to mix class and instance methods on the same class”. Should be re-phrased “Instead, Scala uses a concept called companion objects to mix class and instance methods on the same class”, to be consistent with page 140.

2010-04-03
107TYPO

Second to last line, there is a missing ‘)’ in the sentence ending with: concatenate([1, 2], [3], What.

2010-04-03
8TYPO

inconsistent capitalization: ‘Interpreter’ is capitalized, ‘compiler’ is not (lines 1-2)

2010-04-03
32TYPO

line before last -

numbers = {1 => “one”, 2 => “two”}

does not have interpreter prompt and is not coloured as input

2010-04-03
33TYPO

in the example:

>> def tell_the_truth(options={})
>> if options[:profession] == :lawyer
>> return “it could be believed that this is almost certainly not false.”
>> else
?> true
>> end
>> end

line “?> true” is not coloured as input

2010-04-03
55TYPO

the code lines for Vehicle description appear twice; it would make more sense if the first instance was removed.

2010-04-03
16TYPO

“From the programming side, I speak basic”.

This should be “I speak BASIC” or “I speak Basic”.

2010-04-03
124ERROR

“Think Smalltalk for objects, or Lisp for functional
languages.”

I hardly think Lisp is a pure functional language. It has purity of syntax (or, as Lispers would say, no syntax at all!) but between the dynamic scope of early Lisps (still available in Common Lisp) and all the procedural loop macros, it does not enforce a functional style. In fact, tail-call optimization is not even part of the standard for most Lisps (only Scheme) so you have a category of correct functional programs that are not guaranteed to run under Lisp.

I’d pick Lisp as an example for pure syntax and homoiconicity (you either love it or hate it) and Haskell as a pure functional language.

2010-04-20I dropped the "pure". I think the argument still holds. Lisp was radically different, and very powerful because of the functional concepts it introduced.
143TYPO

5.3, first paragraph, first sentence: “…and his unique
abilities may give him a special a place in the existing society”. Remove the redundant “a”.

2010-04-03
144TYPO

Scala console session at the top: the last two entries look redundant and don’t add anything to the discussion:

scala> def double(x:Int):Int = x * 2
double: (Int)Int

scala> double(4)
res1: Int = 8

2010-04-03
148TYPO

First example, the paragraph above talks about the operator but the example uses the operator again. The example should be:

scala> animals Set(“armadillos”, “raccoons”, “lions”, “tigers”)
res13: scala.collection.immutable.Set[java.lang.String] = Set(lions, tigers)

2010-04-03
147SUGGEST

Discussion on sets on page 147 and 148 should clearly explain that the , -,+, — and operators create new sets rather than updating the sets in place. There is a hint in the fact that Scala uses the scala.collection.immutable.Set class but it should be said explicitly.

2010-04-03
149ERROR

foreach section, paragraph after the first example, first sentence:

hobbit => println(hobbit) is an anonymous function, meaning a higher-order function without a name.

This contradicts the definition on page 148: “In layman’s terms, a higher order function is one that produces or consumes functions.” According to that definition, “foreach” is the higher-order function, while “hobbit => println(hobbit)” is an anonymous function that is an argument to the higher-order function foreach. I believe the definition on page 148 is correct, therefore, the example on page 149 is not.

2010-04-03
157TYPO

First example with the \\ operator, the last line doesn’t belong to this example:

res2: String = Pirates of the Caribean

2010-04-03
29TYPO

paragraph starting ‘Duck typing…’, the word tenant (=person who inhabits a property) should be replaced with ‘tenet’ (=belief or principle)

2010-04-03
47TYPO

“The metaprogramming happens in the ActsAsCsv macro”
should be “The metaprogramming happens in the acts_as_csv macro”. (or I misunderstood what the author is trying to say, but then it’s a problem as well)

2010-04-03
49SUGGEST

The description of metaprogramming would benefit if you add another code example of how classes “can change based on the state of your application”, building up on “acts_as_csv_module.rb”. The example on page 48 only illustrates how to use the technique, plus there is a vague-ish description of how it is used in other people’s code. I hope there is more material coming on Ruby metaprogramming.

2010-04-20I originally had the CSV example much like ActiveRecord, with extra accessors based on the name of the columns in the CSV. I got feedback that the example got too complex, too soon. \n \nI pulled back the complexity of the code. I may decide to add it back in depending on feedback, but I would prefer to use the extra pages and complexity on languages that are a little less known.
48SUGGEST

Shouldn’t all 3 modules in acts_as_csv_module.rb be separate instead of ClassMethods and InstanceMethods being nested in ActsAsCsv as in the pdf? Am I missing a subtle point? It works either way, but (being Ruby ignorant) I suspect nested module definitions do not illustrate the idea of metaprogramming very well.

2010-04-20I'm going to leave this example as it is.
41TYPO

“These examples will force you to do a little more analytic thinking” …analytic… should be analytical

2010-04-03
51TYPO

“…to calculate all addresses codes in a fifty mile radius.” should be “address codes”

2010-04-03
99TYPO

the Waltons was a 1970’s TV show, not 1950’s.

2010-04-03
40SUGGEST

David mentions a redundancy with a.any? but I’d also add that there was no reason to assign a = [5,3,4,1] twice. To have done so seems to indicate that a.sort would have changed ‘a’ but it wouldn’t do so.

2010-04-03
40TYPO

The reference to ‘all’ in the 2nd last para should instead be ‘all?’

2010-04-03
66TYPO

in the example:

Io> i = 1
==> 1
Io> while(i <= 11, i println; i = i + 1); “This one goes up to 11” println

i = 1 should really be i := 1 as i hasn’t been created yet.

2010-04-03
35SUGGEST

The text reads “Like an earlier example you saw, this code opens up an existing class” There was no previous example that added to an existing class. In fact, this is the first time “class” has been used to scope a method.

2010-04-20
28ERROR

While duck typing is a type of dynamic binding I fail to see how delayed binding relates to duck typing as implied in:

“This concept is called delayed binding, also known as dynamic or duck typing.”

2010-04-20
40ERROR

a.sort is called twice and a assigned twice. My guess is that one was supposed to be sort! and show that the array was updated?

2010-04-20
73ERROR

in the phonebook code:

“0 to(call args size - 1) foreach(i,”

“call args” should be “call message arguments”

2010-04-20
42TYPO

“Write a simple grep that will print the lines having any occurrences of a phrase anywhere in a file” do you really mean finding the occurrences of the phrase anywhere in the line, not “in a file”?

2010-04-20
15TYPO

Capital G in Google is probably more appropriate

2010-04-20
87TYPO

There is a missing ending ‘l’ letter in the last name of Phillipe Roussel.

2010-04-20
171TYPO

“Not Threading” title: should it be “No Threading” instead?

2010-04-20
172TYPO

First paragraph, the following two sentences are repeated from the “Not Threading” section on page 171:

Erlang’s creators spent effort to simplify creation, management, and communication within applications
with many processes. Message passing is a basic language-level construct, eliminating the need for locking and improving concurrency.

Besides “Erlang’s creators spent effort to…” should probably be re-phrased.

2010-04-20
97TYPO

The sentence, “We had give the simulated dolphin the same heuristic,” should read, “We gave….”

2010-04-20
56SUGGEST

This page says

“You won’t find much syntactic sugar at all. You’ll just send messages to objects.”

and then a couple of paragraphs later uses what seems to be syntactic sugar in the example:

Io> Vehicle description := “Something to take you places”

Maybe point that out? Otherwise this example is a bit confusing because it does not fit into BNF. It looks like all “:=” and “=” usage is syntactic sugar for “setSlot” and “updateSlot” messages

2010-04-20Good comment, but in situations like this, I use a phrase like "much" to qualify the statement. (The use of "" is also syntactic sugar, but compare this language with, say, Ruby or Clojure.) I don't want to introduce too much too soon.
184TYPO

Day 1 self study finishes with the sentence: “Spend a little time playing with slots and prototypes. Make sure you
understand how prototypes work.”

This doesn’t make sense for Erlang is seems to be an accidental paste from the chapter on Io.

2010-04-20
185TYPO

“If” section, third sentence says “Later, we’ll introduce guards on pattern patches”. This should be “pattern matches”.

2010-04-20
190SUGGEST

Both the paragraphs before and after title “Advanced List Concepts” start with the phrase “So far,…”. Re-phrase the text to avoid the repetition.

2010-04-20
195TYPO

Second “Do” item in Day 2 self-study says: “Write a list composition…”. Replace with “Write a list comprehension”.

2010-04-20
204TYPO

Example at bottom of page, the following is superfluous and confusing:

3> spawn(fun doctor:loop/0).
<0.39.0>

2010-04-20
208SUGGEST

Section on integration. There is a project to create a jvm erlang VM, erjang. It looks fairly new and I don’t know what the current state of it is but it may be worth mentioning.

2010-04-20Thanks for the suggestion. I'll keep an eye on it.
34TYPO

Throughout the ruby code examples in the pdf, the opening and closing curly-braces appear to be from different fonts: the closing brace is definitely more squiggly than the opening brace.

2010-04-20I can't really control this from the markup. Good eye, though! I would not have noticed.
55TYPO

Inconsistent capitalization of titles. e.g. ‘Breaking the Ice’, but on the same level title ‘Objects, prototypes and inheritance’

2010-04-20I'll fix these all at once in the copyedit phase of the book. Thanks for the comment. I'm marking this as fixed to clear the errata for bookkeeping purposes.
74TYPO

This example input file:

{
“Bob Smith”: “5195551212”,
“Mary Walsh”: “4162223434”
}

does not need any commas between entries, they confuse the code so that processing stops after the first key (this is on Windows binary release). E.g.

Io> phoneNumbers asList
==> list(list(“Bob Smith”, “5195551212”))

Without comma the result is as it should be

Io> phoneNumbers asList
==> list(list(“Bob Smith”, “5195551212”), list(“Mary Walsh”, “4162223434”))

2010-04-20
74SUGGEST

In addition to #42763 - everything seems to work with commas if #42650 is corrected.

2010-04-20
153TYPO

“scala>” prompt and highlighting are missing from the following examples:

val words = List(“peg”, “al”, “bud”, “kelly”)
words: List[java.lang.String] = List(peg, al, bud, kelly)

words.count(word => word.size > 2)
res43: Int = 3

words.filter(word => word.size > 2)
res44: List[java.lang.String] = List(peg, bud, kelly)

words.map(word => word.size)
res45: List[Int] = List(3, 2, 3, 5)

2010-04-20
154TYPO

“The, we count all…”

The should be Then

2010-04-20
61ERROR

In the example code, entering

io> elvis asObject

returns

Exception: Map does not respond to ‘asObject’
—————
Map asObject Command Line 1

If I enter

io> Object

the list of returned slots does not include “asObject”.

Regards,
Chip Aspnes

2010-04-20This works for me.
218ERROR

Example a third of the way down the page:

user=> (if “” user=> (if 0 (println “true”))

should be:

user=> (if “” (println “true”))

2010-05-13
219ERROR

First paragraph:

The three main operations for a list are first (the head), last (the list minus the head), and cons (construct a new list given a head and a tail)

This is incorrect, there are four operations: first (the head), last (the last element), rest (the list minus the head), and cons.

2010-05-13
220SUGGEST

The example at the bottom of the page suddenly uses commas between elements while all previous examples only used a white space. The commas work too but may be confusing for the reader.

2010-05-13
221TYPO

Half-way down the page: “Clojure has two kinds for forms that are used to name things in this way, keywords and symbols.”

Should read: “Clojure has two kinds of forms that are used to name things in this way, keywords and symbols.”

2010-05-12
173TYPO

“Distributed message passing is a basic language-level construct, eliminating the need for locking and improving concurrency.”

is repeated twice

2010-05-13
54TYPO

So Ruby’s core strengths are its syntax and flexibility.
(it’s => its)

2010-05-12
58TYPO

Io> Object type
==> Object
(needed prompt before “Object type”

2010-05-12
179TYPO

“Let’s say we want to assign the name to Nirst, and the profession to Profession.”

Nirst?

2010-05-13
185TYPO

“…given input of the form {error Message}…”

missing comma? i.e. should be “{error, Message}”

2010-05-13
63SUGGEST

you say “now you’ll want to iterate over them” but leave the reader there. It feels like you’ve wanted to add a paragraph or so about iteration here.

2010-05-12
186TYPO

“…and i think I heard him laugh”

should be a capital “I”

2010-05-13
189TYPO

“3> Print = fun(X) -> erlang:display(X).”

missing an “end”. i.e. should be:

3> Print = fun(X) -> erlang:display(X) end.

2010-05-13
196TYPO

“[{erlang ”a functional language“}, {ruby ”an OO language“}]”

missing commas. should be:

[{erlang, “a functional language”}, {ruby, “an OO language”}]

2010-05-13
128OK

“(With most object oriented languages, a typical getter would
break that rule.)”

Don’t you mean setter ? That is the method type that breaks immutability.

2010-05-13No, a getter. Execute the function first_name, get one response. Change the state of first name. Then, execute the same function with the same input parameters, and get a different response. \n \nConfused me too at first.
936OK

Io chapter indicates that (Vehicle slotNames) will include “type” but it does not

2010-05-12
1248TYPO

Princess Buttercup’s true love’s name is Westley, with a T, not Wesley.

I hope this makes up for my erroneous report of “type” slot being unreported on vehicles.

2010-05-12
65ERROR

Syntax error just after the first paragraph:

Object clone := ‘hosed’

The ’ slot Io leaves up to the user to define for additional syntax. If this example was meant to show replacing the root level clone object with a string whose contents are hosed, then the single quote ’ needs to be double quote " or triple double quotes “”" around hosed.

2010-05-12
71ERROR

I strongly urge you to consider changing this paragraph:

This little example is beautiful, so read it carefully. Think of doMessage as Ruby’s eval. It just executes code. We’re delaying the execution of the parameters. In a typical object oriented language, the interpreter or compiler would compute all of the arguments, including both code blocks, and place their return values on the stack. In Io, that’s not what happens at all.

Into something that accurately describes Io. Not that this is far off, but it leaves some items out. For example, touching on the first sentence; doMessage is not really like Ruby’s eval(). doMessage evaluates a preconstructed AST. It’s like what you would use to implement an eval(). For example, doString in Io can be implemented in terms of doMessage: doString := method(str, self doMessage(str asMessage)). This takes the argument (assumed to be a string) and creates a message (Io’s AST is just Message objects) and then passes it as the argument to doMessage evaluated against the receiver of the method. Straight forward. doString in the previous example I just gave, is equivalent to ruby’s eval().

Secondly, the wording of the third sentence is misleading. It writes:

We’re delaying the execution of the parameters.

However, Io never defers evaluation of formal parameters. Formal parameters are always evaluated within the context in which they are passed in. I.e., the caller’s scope. Informal parameters however (that is to say, arguments which were not defined at the time the method was defined, such as arguments 0, 1 or 2 in the unless example) are left unevaluated, as message objects accessible in the “call” object within a method or block, for the method itself to decide what to do with. This is where the true power of implementing control flow operations comes in, and it should be clearly marked as such.

2010-05-13
76SUGGEST

Suggest a rework of this as well:

The next line adds an operator to Io’s operator table, speci- fying the core operators in the language. Whenever : is encountered, Io will call atPutNumber on the sender, as you’ll see.

Should probably show an example of how “a : b” gets parsed to make it more clear to the reader. I.e., assignment operators are parsed different to regular operators (which granted, are not demonstrated at all and that’s another point, should be). For example, “a : b” will be parsed (according to the example I wrote, and you published in the book): atPutNumber(“a”, b). This distinction is critical to understanding of how assignment operators work.

As a secondary suggestion, as noted previously, the book should really touch on binary operators as well. Such as the kind of +, -, etc., and how they work. An example is provided, however contrived.

Assume that we want to define a new way of multiplying numbers, let’s call it ’ (single apostrophe). Since this is not a defined operator existing, and we can check this by in the REPL typing: OperatorTable, and looking at the string it returns, we need to add it. We can do this by this code:

OperatorTable addOperator(“’”, 2)

This adds ’ to the operator table at the same precedence level (2, closer to 0 binds more tightly), and now we can define ’ on objects. Let’s just define it on Number to complete this contrived example:

Number ’ := method(num, self * num)

So here, we know what’s happening. Now then, when Io encounters ’ messages in the future, it will shuffle it around adding in (’s and )’s where appropriate based on other operators in the message tree (if any) or carry on to the end of the line. I.e.,

1 ’ 5 factorial

gets parsed as: 1 ’(5 factorial). However:

1 ’ 5 + 7 factorial

would be parsed as: 1 ‘(5) , since binds less tightly than ’.

2010-05-13
76TYPO

In the paragraph starting:

Moving to the right, …

The embedded code has a typographical error. It notes “domessage” when the message name he’s after is “doMessage”.

2010-05-12
92SUGGEST

seems inconsistent: first code asks which are meats and ends with ‘no’ because there are no more… second code asks which flavors are sweet but ends in ‘yes’ because…???

2010-06-08I must confess, I don't know! Does any reader know the difference? If so, you can post the answer here, or drop me a note: bruce at rapidred.com.
217TYPO

First sentence of ‘Booleans and Expressions’: ‘Closure’ should be ‘Clojure’

2010-05-13
219TYPO

Paragraph starting ‘You may…’ : ‘clojure abstraction’ ->‘Clojure abstraction’ (it’s capitailzed in all other uses)

2010-05-13
221TYPO

Under ‘Maps’, after third code example: ‘Closure’ -> ‘Clojure’

2010-05-12
230TYPO

Inconsistency in last paragraph: elsewhere ‘day 2’ is mentioned but capitalized.. should check throughout the text and be consistent.

2010-05-12
102TYPO

Top of page in text ’ The also works in reverse’ … the what?

2010-05-13
105TYPO

Inconsistent typography: ‘Head’ in the first paragraph is written in the same font as the rest of the text; elsewhere (cf. next page) it is written in the sans-serif font.

2010-06-08will wait on the editorial pass for this one.
110TYPO

missing space: ‘..the tail ofTail-A’

2010-05-13Can't find this one... must have already have been fixed. If you still see it, can you post the sentence or paragraph it appears in?
117TYPO

missing plural: ‘Each queen is on two diagonal’

2010-05-13
118TYPO

inconsistent capitalization: ‘Northwest’ on this page, ‘northwest’ on previous

2010-05-13
124TYPO

‘particularly on those…’ should be ‘particularly in those…’

2010-05-13
36TYPO

The yield between begin_transaction and end_transaction should not be indented.

2010-05-12
50TYPO

“should return lions” -> “should print lions”

2010-05-12
35SUGGEST

The “return” in the tell_the_truth function is unnecessary.

def tell_the_truth(options={})
if options[:profession] == :lawyer
return “it could be believed that this is almost certainly not false.”
else
true
end

Having earlier pointed out that return is optional when the last value is to be returned, wouldn’t it re-inforce the point to remove this return?
end

2010-05-12
35TYPO

“If you pass in a :profession of lawyer, you will get something different.”

Shouldn’t that be the symbol :lawyer rather than the variable name lawyer?

2010-05-12
25SUGGEST

On this page you explain the difference between ‘literal strings’ and “strings to be evaluated”. In the examples shown on the page you only uses double quoted strings for strings that need to be evaluated.

In following examples you seem to use ’ and " interchangeably for ‘literal strings’. Using only single quotes for “literal’ strings would re-inforce the message about ”strings to be evaluated".

2010-05-12
41TYPO

Shouldn’t “The filename implements two default methods for safety that we expect clients to override.”

read

“filename is a safety method that we expect clients to override.”

[Also shouldn’t filename be in the “embedded code font”?]

2010-05-12
47OK

on OPEN CLASSES:
———————————————————-
Case missmatch on code sample and explanation:
Roman.X (sample)
Roman.iv, Roman.i … etc (explanation)

2010-05-13I don't think I'm going to fix this one. A downcase would be easy to add, but I want to keep the example simple, and it works as it is.
42SUGGEST

I would have found it easier to understand if you had written

“Since the spaceship operator is implemented by Fixnum, you can sort and compute the min or max of these integers as sort, min and max all make use of the spaceship operator.”

instead of

“Since the spaceship is implemented on these integers through Fixnum, you can sort, compute the min or max.”

2010-05-12
42SUGGEST

I don’t see how the paragraph starting “You can also do set-based operations.” relates to the Modules and Enumerable heading.

Perhaps you could explain the linkage.

2010-05-12
42TYPO

“apply a function” => “apply a block”

2010-05-12A code block is an anonymous function. I'm going to leave this alone, because I want the reader to get used to that concept.
153TYPO

First code line at top of page says “forech” instead of “foreach”

2010-05-13
60TYPO

The line “ferrari getSlot(”type“)” is missing the Io prompt and should be “Io> ferrari getSlot(”type“)”.
This is right before the sentence: “You can get the prototype of a given object:”

2010-05-12
61TYPO

Object should be spelled uppercase in the sentence “object supports the list method which …” after the code examples in the “Lists and maps” section.

2010-05-12
10TYPO

Last sentence of 3rd paragraph:

“The is the quickest way to mastering a skill.”
should be
“This is the quickest way to mastering a skill.”

2010-05-13
10TYPO

5th paragraph:

“… your subconscious is figuring our the deep meaning …”
should be
“… your subconscious is figuring out the deep meaning …”

2010-05-13
14SUGGEST

The first sentence about Io would probably read better as:

“Along with Prolog, Io is the most controversial language I included.”

2010-05-13
211OK

The link between the last sentence: Before diving in too deeply, let’s talk a little bit about Lisp, and then shift gears to what’s exciting about Clojure.

The title of the next section: Introducing Clojure

And the first subsection: All Lisp

Seems strange to me (I’m not a native english).

2010-06-08
220TYPO

Last parentheses in the examples should be in blue (they are in green).

2010-07-26
27SUGGEST

puts “This appears to be true.” unless x == 4

A little confusing, perhaps “I appear if I am false”?

If x wasn’t == to 4, then the statement “this appears to be true” would be printed, which would not be correct.

2010-06-08
62TYPO

“elvis := Map clone” line is missing the Io prompt

2010-06-08
64SUGGEST

Could be useful to explicitly show the equality of fred and mike before showing the inequality of one and two.

2010-06-08
56ERROR

The BNF description doesn’t seem to be correct (I know it’s copied from the iolanguage.com site, but there it’s given as an informal BNF description; here it’s given as “the entire syntax”).

Some problems are:
1. The paragraph following the BNF block starts with “Receiver, space, message, parameters, repeat.” But nowhere in the BNF is there any mention of “Receiver”.
2. It’s unclear to me how items such as + and < fit into this BNF. (A previous comment has already pointed out hte problem with := and =.)
3. The line
arguments ::= “(” [exp [ { “,” exp } ]] “)”
while technically correct, has an extra set of square brackets that really irritates us BNF-geeks. Since {} indicates 0 or more repetitions, there’s no need to include the {} in a []. The line would be better stated as:
arguments ::= “(” [exp { “,” exp } ] “)”

2010-06-08
226TYPO

The correct name of that big guy from Star Wars is Jabba, not Jaba :)

2010-06-08
226TYPO

..and Jabba is not a bounty hunter, he is some sort of gangster.

2010-06-08
59TYPO

Typo in the word “just”:
“A method is an object, jut like any other type of object. You can get its type:”

2010-06-08
60TYPO

Missing example.
“And you can get all of the slots that a class supports. Some will be methods, and some instance variables:” has no example after the colon.

2010-06-08
64TYPO

like changing a method’s clone method to make a singleton.

Think you might have meant “changing an object’s clone method […]”

2010-06-08
81TYPO

page 81:
“But we can easily make each object run in its own
thread by preceding each message with @, meaning send an asynchronous message" page 79: "You can fire a message asynchronously by using before a message.”

Is there a difference or is @@ a typo?

2010-06-08
82SUGGEST

“Futures” section looks unfinished - it uses chunks of code not belonging to any object then refers to an undefined object “backToThePast” which probably contains the code in question

2010-06-08
68OK

while(i <= 11, i println; i = i + 1); “This one goes up to 11” println

This does not work:

Io> while(i <= 11, i println; i = i + 1); “This one goes up to 11” println
This one goes up to 11
==> This one goes up to 11
Io>

2010-07-20Works for me. Did you make sure to set i?
39TYPO

In the code fifth line from bottom:
puts ruby_tree.visit {|node| puts node.node_name}
remove the first puts.

2010-06-08
26TYPO

“… ans the method called methods returns an array of of methods … ”

The second ‘of’ should be removed.

2010-06-08
92SUGGEST

Explanations to “yes vs. no” in #43048:

"In some cases the top-level can detect that the current solution is the last one (no more alternatives remaining). In such a case it does not display the ? symbol (and does not ask the user). Example:

| ?- (X=1 ; X=2).

X = 1 ? ;\t \t(here the user presses ; to compute another solution)

X = 2\t \t(here the user is not prompted since there are no more alternatives)

yes"

(from gprolog manual - cannot post links here)

2010-06-08
126SUGGEST

“In this sense, Scala is a Frankenstein of sorts, but not a monster. Think Edward Scissorhands.”

Contrary to popular opinion, Frankenstein is not the name of a monster, but of a scientist who created the monster. I dont think this is the idea you are invoking.

2010-06-08
29TYPO

The installation instructions for Ruby say that “Ruby comes with the X-code disks.”. Unfortunately, there is no such thing as X-code. The correct name for the OS X developer tools is Xcode, capitalized exactly like that.

2010-06-08
33ERROR

The bit about & and | being non-short-circuit versions of && and || is mostly incorrect. & and | are only non-short-circuiting logical operators when used with true/false/nil. When used with other objects they behave differently; most notably they are the bitwise operators for numeric classes and the Intersection/Union operators for Array/Set. This distinction is fairly important, especially as this section comes immediately after demonstrating that all objects besides nil/false are treated as true in a conditional.

2010-06-08
34TYPO

In the epub version of this book, all instances of a backtick (`) are showing up as the LOWER RIGHT PENCIL character (✎). I checked to make sure this wasn’t some strange bug in iBooks and the html files really do contain this character.

2010-07-20
65ERROR

On PDF Page #62 we updated the Vehicle description to be “Something to take you far away”, but Figure 3.2 on PDF Page #65 indicates that it’s still “Something to take you places”.

2010-06-08
66TYPO

Second paragraph of Methods says “A method is an object, jut like any other type of object”. The word “jut” should be “just”.

2010-06-08
64SUGGEST

Wouldn’t the ferrari object have a ‘type’? Oh wait, it’s a capitalization thing? Highlighting that would probably be helpful…

Io> Ferrari := Car clone
==> Ferrari_0x9d085c8:
type = “Ferrari”

Io> Ferrari type
> Ferrari Io> ferrari := Car clone > Car_0x9dd2440:

Io> ferrari type
> Car Io> Ferrari slotNames > list(“type”)
Io> ferrari slotNames
==> list()
Io>

2010-06-08
80OK

The example with westly is mildly confusing. I expected it to actually do something with princessButtercup, but it turns out that the presence of this object is completely unnecessary, and removing it from the example would change nothing.

2010-07-20I'm showing the flow of a message. buttercup is the target, so it's necessary.
80TYPO

The indentation in the ancestors method of the io/animals.io example is a bit confusing and feels like a mistake. It indents the first and 3rd lines of the if block, but not the 2nd or the 4th.

2010-06-08
48OK

The Do #2 question says to specify the tree like this:

{’grandpa’ => [{’dad’ => [‘child 1’, ‘child 2’]}, {’uncle’ => [‘child 3’, ‘child 4’]}]}

when it should be:

{’grandpa’ => [{’dad’ => [{’child 1’ => []}, {’child 2’ => []}],
{’uncle’ => [{’child 3’ => []}, {’child 4’ => []}]}

2010-06-08
289TYPO

double-colon in the third myRange example

1:2::3:myRange (4 1)
should be
1:2:3:myRange (4 1)

2010-06-08
275TYPO

The first code snippet this page, “haskell/fact_with_guard.hs” appears to be invalid. Here it is:

module Main where
factorial :: Integer -> Integer
factorial x =
| x > 1 = factorial x = x * factorial (x - 1)
| otherwise = 1

I think it should be:

module Main where
factorial :: Integer -> Integer
factorial x
| x > 1 = x * factorial (x - 1)
| otherwise = 1

I’m using ghci v6.12.1.

2010-06-08
82TYPO

Question 4 asks me to add a slot to list that computes the average of all numbers in the list. Two problems. First, the type is List, and second, List already has a slot called “average” that does precisely this.

2010-06-08
91TYPO

The example for self study problem 3 has a couple of stray quotes.

2010-06-08
41TYPO

“This style of programming, made famous in Smalltalk is called a mixin.”

The apposition “made famous in Smalltalk” is missing a comma.

2010-06-08
48SUGGEST

“Macro” is introduced as an idea, but there’s no scope placed on the name “Macro”. These days, I think the majority of people think “Macro” is something you do in Visual Basic for Applications or Apple’s Automator widget. I have heard of “Hygienic Macros” from a friend who detested their introduction into Scheme or Lisp when it destroyed his use of (apparently) non-hygienic macros. But I’m not sure if these macros are the same as those macros, or what their relationship with CPP’s macros might be.

So some idea if this term is Ruby-specific or common to the larger world of programming languages would be superb. At least for me. :)

2010-06-08
53SUGGEST

“In formal big enterprises with distributed transactions, failsafe messaging, and internationalization, the role of Ruby is a little more limited.”

How does Ruby fall short with internationalization? Granted, C’s _() gettext() is really convenient to use, but it forces translators into some pretty awkward sentences when the natural order of replaced elements is different from the ‘native’ language of the application. Ruby’s interpolated strings make this process way easier, since translators can move the interpolated variables around as they need to. It might still fall a little short when sentences require four versions for different pluralizations, but it’s doable.

(Slovenian requires four different pluralization forms. Croatian, Czech, Gaeilge, Latvian, Lithuanian, Polish, Romanian, Russian, Serbian, Slovak, Ukranian all require three different pluralization forms. And Ruby’s interpolated variables-into-strings and I18n library make this sort of thing possible, but C’s gettext() can’t hope to come close without significant application work.)

2010-06-08
54OK

I’ve always had an ‘iffy’ feeling about duck-typing. When I’ve complained in the past, a friend said, “you’re just worried because you don’t have adequate test coverage of your application.” (This statement is probably true for nearly everyone.)

But it does bother me that the language isn’t going to help me figure out what API a duck needs to implement for some other piece of code to treat it like a duck. Maybe ducks need to quack, eat, and fly most days of the year, but every February 29 a duck also needs to bite a goose in the butt. How would an ersatz-duck-author know this? Only by reading the entirety of the dependent code! (Or, very kind dependent code authors, who publish an up-to-date list of all methods they require.)

Java Interfaces, for all that they don’t bother to do, at least do tell programmers pretty clearly what API they need to support. Python’s Twisted framework has run into this very issue with duck typing, and they’ve slapped a home-grown interface mechanism into their code. It feels pretty tacked-on.

How is duck typing handled in the real world? I’ve only ever written self-contained applications in duck-typing languages, where it hasn’t even been an issue: either feature or a detriment.

2010-07-26That's a good question. I hope you like the alternatives presented in the Scala and Haskell chapters.
70TYPO

“He said ”Bruce, there’s …"

s/said/said,/

2010-06-08
109TYPO

concat_step_1 has been included into the text twice. The second time it is included would be the logical place to include concat_step_2 into the text, but it is included later — after it has been used.

2010-06-08
129SUGGEST

“Strictly speaking” has been used twice in two paragraphs. Unless used for parallel construction, duplicated introductory phrases feel funny to me.

2010-06-08
132TYPO

“like java.lang.String Please trust me,”

s/String Please/String. Please/

2010-06-08
146TYPO

Copy-n-paste from Scala console is missing the leading “scala> ” prompt in the section “var vs val”, code line: var mutable = “I am mutable”

2010-06-08
17SUGGEST

“I am going to make a deal with you. You agree to let me focus on the programming language rather than installation details.”

THANK YOU. I can’t tell you huge a waste of time I’ve thought it is for language books to waste an entire 12-24 pages on how to install one specific version of their language. Notes of specific versions used are fine, comments on more-reliable vs known-flaky versions are fine, but thank you so much for bucking the trend on including complete installation instructions.

I can’t say it enough :) thank you.

2010-06-08
120ERROR

“Find:
• Some alternative implementations of a fibonacci series and factorials.
How do they work?”

There are no implementations of fibonacci or factorial in Prolog chapter

2010-07-20
169ERROR

“We implemented a factorial
example by having a Prolog rule for zero and one for integers greater than zero.”

There is no factorial example in Prolog chapter

2010-07-20
186SUGGEST

It is not clear what you mean by saying “I’m working with version 5.7.3” - it seems you are referring to the version of the interpreter and not the platform release itself, which is
“Erlang/OTP R13B04” at the moment.

2010-07-20
194SUGGEST

“Erlang is the first language you’ve seen so far that has no notion of an object.” - not entirely true since Prolog did not have any objects either.

2010-07-20
196TYPO

6> if
6> ProgramsTerminated > 0 ->
6> success;
6> ProgramsTerminated < 0 ->
6> error
6> end.

Output is missing at the end of the page

2010-07-20
91TYPO

Problem 3 has multiple problems, not just the quotes: a) consistent double quotes, b) spelling of “Tate”, c) the XML element name should be “book”

2010-07-20
202SUGGEST

15> [[2, 3] | 1].
[[2,3]|1]

pipe symbol in the output could use some explanation.

2010-07-20
217SUGGEST

“* An OTP service that will restart a thread if it dies”

You mention that Erlang processes are not quite threads several times, so perhaps the above should be rephrased?

2010-07-20
160TYPO

“Figure Figure 5.1, on the following page lays it all out.” (Reads “Figure Figure Any and Nothing” in the epub version.)

2010-07-20
161ERROR

Figure “Any and Nothing” extends off the page in the PDF. (The epub version almost fits on my Sony Reader.)

2010-08-21Will fix this in typesetting stage
169ERROR

The code example with movie_nodes(0) is leaking some underlying book markup: “We just found element number zero,…TRUNC”. I assume the close-code, p, text, close-p, and open-code tags should all be hidden behind the scenes, controlling the book’s layout. (Working with XML within XML must be annoying. :)

2010-07-20
171TYPO

“you place an object on it’s queue.”

s/it’s/its/

2010-07-20
176TYPO

“Form example, sizer for ”google.com“”

s/Form/For/

2010-07-20
177TYPO

“Finally, the message passing syntax you see in Io is much like you will see in the next chapter on Erlang.”

s/Io/Scala/

2010-07-20
160SUGGEST

I suggest including the nine-nines anecdote; deployed AXD301 systems showing 99.9999999 % uptime while handing 30-40 million calls per week. People in the software industry understand the achievement of five-nines, and nine-nines should wake people out of a drudgery-induced stupor. :)

2010-07-21
184TYPO

“really nice to go back the roots of Erlang”

s/go back the/go back to the/

2010-07-20
187SUGGEST

“[Atoms] are single-byte values that you can use to represent something.”

Does this mean that erlang systems can have a maximum of 255? 256? atoms? What happens when the 256 or 257th atom is added to a program? .. Or is this a case for self-study?

2010-07-20
190TYPO

“with predefined formats like JPegs or MPegs”

“JPEGs”, “MPEGs” is usual; “jpegs”, “mpegs” is kinder to the eye. But “JPeg” and “MPeg”, I’ve never seen this one before. :)

2010-07-20
195TYPO

“What about turning a list of URLS into tuples…”

s/URLS/URLs/

2010-07-20
198TYPO

“The lists::foreach method takes a function and a list.”

s/::/:/

2010-07-20
198SUGGEST

“The first argument is an anonymous function that looks like fun(Number) -> erlang:display(Number) end.”

Suggest removing “that looks like” — it is that. (Cue Haddock’s Eyes…)

2010-07-20
199TYPO

“Finally, the third argument is Numbers…”

“Numbers” is the second argument of lists:foreach/2. (“Number” is a formal parameter, not yet an argument..)

2010-07-20
202SUGGEST

This Erlang had me confused:

14> [1| [2, 3]].
[1,2,3]
15> [[2, 3] | 1].
[[2,3]|1]

I’d like to suggest a mention that [a,b] is syntactic sugar for [a | [b]], and [a,b,c] likewise for [a | [b | [c]]]. Only after finding this, and fifteen minutes play time in the shell, did I figure out why [[2,3]|1] displays like it does. (The line from the language spec, “However, this type of list is of little practical use.”, made all the difference in the world for me. :)

2010-07-20
210TYPO

“Let’s turn the translation service that prints return values into a service that actually returns the translated service to the user.”

s/service to the user/string to the user/

2010-07-20
229TYPO

“Now, let’s move into a close cousin of list”

Suggest s/move into/move to/

2010-07-20
237TYPO

“It takes a function that is a test, and returns the element of a list that pass the test.”

Suggest: “It takes a function that is a test, and returns a list of elements that pass the test.”

2010-07-21
244TYPO

“The list comprehension combines maps and filers, as you saw in Erlang and Scala.”

s/filers/filters/

2010-07-21
246TYPO

“we again build a cycle, drop the first two, and take the first two after that.”

s/take the first two/take the first five/

2010-07-21
249TYPO

Clojure source:

(deftype SimpleCompass [bearing]
:as this
Compass

Missing a close-parenthesis.

2010-07-21
250TYPO

“You can verify that entering (String. ”new string“) into the repl returns the new string ”a“.”

s/“a”/“new string”/

2010-07-21
250TYPO

“you can assess all fields as Java fields.”

s/assess/access/

2010-07-21
251TYPO

“The form is (unless test form1). The function will execute form1 is the test is false, otherwise it will execute form2.”

There is no form2 in the desired form — looks like a desired feature (or complicating feature) was dropped, and a stray bit remains.

2010-07-21
252TYPO

In Clojure code:

user=> (macroexpand ’’something_we-do-not-want-interpreted)
(quote something-we-do-not-want-interpreted)

something_ vs something-.

2010-07-21
237ERROR

Clojure code:

user=> (map #(* 2 (count %)) people)
(6 14)

The PDF syntax-highlighting is treating the # reader macro as a comment start character, and turning half the input line green.

2010-09-01prags? This looks like we're treating the # as a ruby or shell comment.
252OK

“The secret sauce is the expression of data as code, and not just a string.”

Is it data as code? Or code as data? Or does LISP make the difference completely irrelevant? How many one-handed LISP programmers does it take for a tree to fall in the woods?

What does Clojure really look like when the data isn’t hard-coded into the program source? Does the data/code division come back?

2010-07-21
253TYPO

The “Find:” section does not use periods, the “Do:” section does use periods.

2010-07-21
258TYPO

“This example is provided courtesy of Stuart Halloway of”

In the PDF, it ends, “Halloway of ^4, a consultancy…”.
In the epub, it ends, “Halloway of [9], a consultancy…”.

Better to just say “ThinkRelevance” in the text, and leave out the web address.

2010-07-21
262TYPO

“we placed all mutations to to refs within transactions”

s/to to/to/

2010-07-21
263TYPO

“a customer sites in the chair”

s/sites/sits/

2010-07-21
279TYPO

“It’s an effective way to combine two”

That’s the whole paragraph. :) Maybe just adding “lists.” is all that is needed, but perhaps there is more planned for this paragraph.

2010-07-21
281ERROR

The Haskell code:

Prelude> [ (y, x) | (x, y) <- [(1, 2), (2, 3), (3, 1)]]
[(2,1),(3,2),(1,3)]

is included twice; the second time, the code should read:

[ (4 - x, y) | (x, y) <- [(1, 2), (2, 3), (3, 1)]]
[(3,2),(2,3),(1,1)]

2010-07-21
238TYPO

“This is the last interview from a language creator in this book, but it’s a good one.”

For the Haskell chapter, there are two more language creator interviews.

2010-07-21
290TYPO

“Here are the functions in action”

missing :

2010-07-21
291TYPO

“You’d do so with the >.> operator.”

We shouldn’t see the >.

2010-07-21
297TYPO

“Triplet is a type constructor, and Trio is a data constructor.”

This sentence is in the wrong paragraph; move it down several paragraphs. I suggest placing it immediately before the sentence beginning, “We’ve built a whole template…” (I like the directness of this sentence; even though it might be redundant with the surrounding text, this sentence is very clear and concise.)

2010-07-21
300ERROR

“C” is broken across two lines in the epub version.

2010-08-21will fix in typesetting
302ERROR

The drunken pirate stagger is described “Each move reverses the direction”, and the Ruby code is implemented to support the reversed-direction behaviour. (The stagger and crawl functions could reverse the direction, but without their implementation, it’s not clear that they do reverse the direction.)

The Haskell implementation of the drunken pirate walk does not include any mention of direction. Since the monad discussion is already complicated enough, I suggest removing the direction from the introduction and Ruby example.

2010-07-21
305TYPO

“And now, you can finally see why we called this the monad’s wrapping construct return.”

Suggest: “And now, you can finally see why we called our monad’s wrapping construct return.”

2010-07-21
308TYPO

Inconsistent ‘.’ at the end of “Find:” section versus “Do:” section.

2010-07-21
306OK

First, this is the best description of monads I’ve seen yet. I think I almost understand them. Thanks! (I’ve been working on it since 2000 or 2001, off and on.. I’m so glad I had a course on Haskell back in school, otherwise this might be too much now.)

But I’m completely lost with the phrase “computational strategy”.

I had almost completely accepted the idea that monads were just a societal convention about wrapping data storage with controlling functions and a new syntax to replace f(g(h()) (there’s no \\circ key on the keyboard, so the standard mathematical \\circ notation wouldn’t work well) — but then the computational strategy phrase came into the picture, and I lost it all again.

Perhaps orthogonal: once you used ‘return’, once you used ‘rtn’. Is the choice of name for the ‘return’ function strictly conventional? Is there one convention that rules?

How about >>=? (The sentence “A bind function called >>= that unwraps a function.” makes me think it is only a convention.) I’m further confused when I see both >>== and >>=. Are some typos? Or is the name completely arbitrary? Could it be called “seth”? What name is most idiomatic in the Haskell community?

Thanks

2010-07-27
138TYPO

Change “it’s” to “its” in “…Twitter has changed it’s core…”

2010-07-20
235TYPO

user=> (defn center [[_ [_ c]] c)
java.lang.Exception: Unmatched delimiter: )

you are missing a right bracket in 2 examples on this page

2010-07-20
236TYPO

“Let’s use a higher order function to build a list of word counts, given a
list of words. Let’s say we have a list of person names:
user=> (map people count)
java.lang.IllegalArgumentException:
Don’t know how to create ISeq from: core$count__3569”

It seems the example (and the error message) is out of place and you intended to have a list definition here instead

2010-07-20
271SUGGEST

“This error message gives us the first glimpse into Haskell’s type system. It says “There is no function called + that takes a Num argument followed by [Char], a list of characters.”"

I think the error message means that while evaluating “+” (which is known to take only Num types) function the interpreter found out that [Char] type does not belong to Num family and thus it could not infer the type to use. So, basically, “[Char] is not a Num(ber)”. Subtle difference, perhaps.

2010-07-26I know this is a subtle oversimplification, but I don't want to introduce classes yet. I clear this up in more detail later in the chapter.
143TYPO

“So my thinking of static typing was shaped by by the Java wars.”

Remove a “by” :)

2010-07-20
150TYPO

You’ve see how the basic constructor works.

see -> seen

2010-07-20
33SUGGEST

“meaning the compiler will only execute code”.

Wouldn’t ‘interpreter’ instead of ‘compiler’ be better?

2010-07-20
68TYPO

“Io> toDos size
’==> 2”

s/’//

2010-07-20
48OK

“Do” example number 1: printing contents of an array (slice) is a bit vague. Should I print each slice as a whole? Use the p() function for pretty output?print the numbers in each slice on a line, separated by space?

I realise it’s just a small example but you can print array contents in many ways.

2010-07-20
152TYPO

On the last line of the page, “Nicetrait” should be “Nice trait”.

2010-07-20
19TYPO

“But unlike Lisp dialects, the
parentheses are greatly reduced, …”

should probably read

“But unlike other Lisp dialects,the ….”

Since clojure is itself a Lisp dialect.

2010-07-20
155?TYPO

“put Scala through it’s paces as a functional”

s/it’s/its/

(Sorry for no exact page number, epub numbers don’t match pdf, and I’m without the pdf right now.)

2010-07-20
319TYPO

“Haskell and Erlang are standalone languages. Haskell and Erlang are standalone languages.” - sentence repeats

2010-07-21
321TYPO

“The next generation of programmer will demand more out of his language.” - “programmers”, perhaps?

2010-07-21
51ERROR

{’grandpa’ => [{’dad’ => [{’child 1’ => [ ]}, {’child2’ => [ ]}]}, {’uncle’ => [{’child 3’ => [ ]}, {’child 4’ => [ ]}]} ]}

this is ok, but in text there is a bracket missing(after dad/child2 resulting in syntax error in ruby1.9

2010-07-20
65TYPO

Vehicle slotNames
==> list(“type”, “description”)

I think, the first line should start with “Io >” and the content should be formatted in red bold.

2010-07-20
40ERROR

>> [1].methods.include?(‘[]’) => true

It returns false on 1.9 because the “methods” method returns an array of symbols in 1.9 (not Strings), so you need to use [1].methods.include?([]:). This also applies to the example on page 32 (though it doesn’t result in an error).

Not a big deal, but I’m interested in why the book is using 1.8 when 1.9 has been around for so long.

2010-07-20
323SUGGEST

It doesn’t make sense to have “Prolog” twice in the sentence beginning:
We first encountered this programming construct in Prolog,
but we also saw it in Prolog,

2010-07-21
284TYPO

In the subsection “List Comprehensions” the first sentence has “We first looked at list list comprehensions”.

2010-07-21
208TYPO

Example 8. should be
—-
8> WithTax = [{Product, Quantity, Price, Price * Quantity * 0.08} || \t{Product, Quantity, Price} <- Cart].
—-
not
—-
WithTax = [{Product, Quantity, Price, Price * Quantity * 0.08} ||
8>\t{Product, Quantity, Price} <- Cart].
—-

2010-07-20
142TYPO

“Twitter has switched it’s core…” should use “its” instead.

“Functional programs avoid changing state, or muting data…” probably needs “mutating” instead of “muting”.

2010-07-20
158TYPO

“Now it’s time to put Scala through it’s paces…” should be “Now it’s time to put Scala through its paces…”

2010-07-20
147SUGGEST

The line “The industry invested hundreds of millions of dollars
in three versions of Enterprise Java Beans, Spring, Hibernate, JBoss, and Aspect Oriented Programming …” read very hard for me because I read it as three versions of each of the following: Enterprise Java Beans, Spring, etc.

Maybe move the three versions until after Spring so it reads “The industry invested hundreds of millions of dollars
in Spring, three versions of Enterprise Java Beans, Hibernate, JBoss, and Aspect Oriented Programming…”

I wish you had time to do more rewriting here. I’m not really sure what you’re trying to say. Are you admitting a bias for or against static typing?

2010-07-20
175TYPO

“you place an object on it’s queue” should use “its” instead of “it’s”

2010-07-20
188TYPO

“We can do this
in library code but its not supported in the language.”
should use “it’s”.

2010-07-20
203TYPO

The anonymous function assigned to print uses Number incorrectly when X has been used as a parameter.

Print = fun(X) -> io:format(“~p~n”, [Number]) end.

Should probably be:

Print = fun(X) -> io:format(“~p~n”, [X]) end.
or
Print = fun(Number) -> io:format(“~p~n”, [Number]) end.

2010-07-20
143DEFER

“I’m using version 2.7.7.final for this book.”
I suggest using Scala 2.8.0 final. Despite the version number it fixes huge amounts of bugs found in Scala 2.7.x.

2010-09-01I did add a footnote to the deprecated methods you mentioned, but can't upgrade to version 2.8 so close to production without lots of quality control on everything.
161ERROR

“You can try to index with a negative number […] but Scala will always return the first element. That behavior is a little inconsistent with the NoSuchElement exception for an index that’s too large.”

This was fixed:

scala> List(1,2,3)(–1)
java.lang.IndexOutOfBoundsException
\tat scala.collection.LinearSeqOptimized$class.apply(LinearSeqOptimized.scala:54)
\tat scala.collection.immutable.List.apply(List.scala:46)
\tat .(:6)
\tat .()
\tat RequestResult$.(:9)
\tat RequestResult$.()
\tat RequestResult$scala_repl_result()
\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
\tat java.lang.reflect.Method.invoke(Method.java:597)
\tat scala.tools.nsc.Interpreter$Request$$anonfun$loadAndRun$1$$anonfun$apply$15.apply(Interpreter.scala:996)
\tat scala.tools.nsc.Interpreter$Request$$anonfun$l…

Later on that page:
“scala> Nil
res33: Nil.type = List()”

This is what 2.8 returns:
“scala> Nil
res6: scala.collection.immutable.Nil.type = List()”

2010-08-21
162ERROR

This:
scala> animals Set(“armadillos”, “raccoons”, “lions”, “tigers”)

should be:

scala> animals & Set(“armadillos”, “raccoons”, “lions”, “tigers”)

Because in 2.8.0 is deprecated:

“scala> animals Set(”armadillos“, ”raccoons“, ”lions“, ”tigers“)
:7: warning: method in trait SetLike is deprecated: use & instead
animals Set(”armadillos“, ”raccoons“, ”lions“, ”tigers“)
^
res1: scala.collection.immutable.Set[java.lang.String] = Set(lions, tigers)”

2010-08-21I can't upgrade to Scala 2.8.0 so close to production, but I can footnote deprecated methods. Thanks for pointing this out. (When there's an alternative that works on the previous version, I'll use it. )
163DEFER

This:
“val ordinals = Map(0 -> ”zero“, 1 -> ”one“, 2 -> ”two“)”
has a slightly different output in 2.8:

“val ordinals = Map(0 -> ”zero“, 1 -> ”one“, 2 -> ”two“)
ordinals: scala.collection.immutable.Map[Int,java.lang.String] = Map((0,zero), (1,one), (2,two))”

2010-08-21can't upgrade to 2.8 so close to production
163DEFER

This:
“scala> map
res2: scala.collection.mutable.HashMap[Int,String] =
Map(4 -> four, 8 -> eight)”

Has a slightly different output on 2.8:
“scala> map
res3: scala.collection.mutable.HashMap[Int,String] = Map((4,four), (8,eight))”

2010-09-01
163DEFER

Instead of:
“scala> map += ”zero" -> 0
:7: error: overloaded method value += with alternatives (Int)map.MapTo
((Int, String))Unit cannot be applied to ((java.lang.String, Int))
map += “zero” -> 0
^
"

the improved error message in 2.8 is:
“scala> map += ”zero" -> 0
:8: error: type mismatch;
found : (java.lang.String, Int)
required: (Int, String)
map += “zero” -> 0
^
"

2010-09-01
164ERROR

“An empty collection is Nil, […]”
An empty List is called Nil, but it has nothing to do with Null or Nothing. Nil is actually an (singleton) object.
I would remove that half-sentence it is not related to the thing you are trying to explain.

More important is that Nothing has no instance. You can’t dereference it like null, it stands for some sort of abnormal termination or non-termination of e. g. a method.
A method which throws an Exception for instance has the return type Nothing.

2010-08-21
165ERROR

The picture is wrong. Every Scala class inherits from ScalaObject, so List just be under ScalaObject and not next to it.

2010-08-21
167ERROR

“scala> list.last
res26: java.lang.String = pippin”

is mentioned twice at that page.

Remove the first appearance of it, and leave the second one after head and tail, because head and tail are more important than last.

2010-08-21
169ERROR

“words.sort((s, t) => s.charAt(0).toLowerCase < t.charAt(0).toLowerCase)”

sort is deprecated, use sortWith.

toLowerCase is deprecated, use toLower.

“scala> words.sortWith((s, t) => s.charAt(0).toLower < t.charAt(0).toLower)
res13: List[java.lang.String] = List(al, bud, kelly, peg)”

2010-08-21
169ERROR

“scala> words.sort((s, t) => s.size < t.size)”

sort is deprecated, use sortWith.

2010-08-21
^176ERROR

The code has:

"
case object Poke
case object Feed
"

but in the text:

"
In this program, we create two empty, trivial classes called Poke and Feed.
"

I would either call them objects or singletons, not classes.

2010-08-21
65OK

In the pdf, it reads: “Vehicle slotNames ==> list(”type“, ”description“)”

my list of members doesn’t have quotes around type and description (i.e., my output is: “Vehicle slotNames ==> list(description, type)”)

2010-08-21This output is version specific. I don't want to change the version I'm working on just before publication date.
304ERROR

Figure 8.1 is wider than the page and chopped off at the right hand side. Viewing in Preview on OS X.

2010-08-21
33ERROR

The unless x == 4 else clauses seem to be backwards.

unless x 4 puts 'This appears to be true.' else puts 'This appears to be false.' end => This appears to be false. but x 4 is true.

2010-08-21
84OK

animals.io works fine if run as a file but does not seem to work if you enter it in the interpreter. I get Exception: Duck does not respond to ‘prototype’

2010-08-21
86TYPO

For the phone book structure to work properly as a “curlyBrackets” method I believe it is necessary to separate the individual name:value pairs with a comma, as you would with regular method arguments; so:
{
“Bob Smith”: “5195551212”,
“Mary Walsh”: “4162223434”
}

2010-08-21
87ERROR

Just a “heads-up”; I think there is a bug when iterating over a Range object represented by 0 to(1). Doing something like the following results in an infinite loop:

a := 0 to(1)
a foreach(i, writeln(i))

Same goes for:

a := 0 to(1)
a last

Given that the phone book example on page 86 contains two items, attempting to run the code on page 87 ultimately results in an Exception because the foreach loop in the curlyBrackets method doesn’t exit like it should after two iterations; this causes the “call message arguments at(i)” to return nil.

You can test this by simply adding a third item to the phone book, which works without issue.

2010-08-21
87ERROR

Io Language: In the “phone number” example Jason already mentioned that you need to add commas after every entry in the phones file.

There is another workaround, you can leave the phones file the way it is and change to code to evaluate the whole file as one message. Replacing curlyBrackets like so:

curlyBrackets := method(
r := Map clone
r doMessage(call message arguments at(0))
)

2010-08-31
122TYPO

Just before the bullets and starting with “I’ll mark the important one with a letter…”: should be “ones”. [Tail2-A] should just be Tail2-A in the right-hand sides. The last bullet brings in Tail2-2, which should be Tail-2-B and [1|Tail2] should be [1|Tail2-A].

2010-08-31
119ERROR

2nd paragraph, 5th sentence starts with “The imperative interpretation is…” but should say “The declarative interpretation is…”

2010-08-31
87OK

The download box/link appears at the start of every program segment of phonebook.io instead of just before the entire program. Very distracting.

2010-08-31It's a callout to an existing file, so I'm going to leave it as it is.
102TYPO

…thru 104. “velveeta” has two e’s in it (not “velveta”).

2010-08-31
117ERROR

In the middle of the page, the output after “[a, b, c] = [a|[Head|Tail]].” goes on for too long. There is only one solution (the first). The second, Head = c and Tail = [], does not unify with this query (and if it did, it shouldn’t have - it certainly doesn’t in other Prologs).

2010-08-31
131TYPO

Middle of page, after rows defn, 1st sentence: “…from the first queen in matches the first element…” “in” is extraneous (or missing words “in the list”).

2010-08-31
131TYPO

The sentence across the page break to page 132: “It’s an is predicate…” should just be “It’s a predicate…”

2010-08-31
137TYPO

2nd sentence under “Utility”: “…had some limitations…”; “had” should be “has”.

2010-08-31
144ERROR

2nd paragraph, 2nd from last sentence: “That’s a significant
departure from most functional languages.” Don’t you mean statically-typed object-oriented languages?

2010-08-31
147TYPO

Last paragraph of shaded box, 1st sentence: “…was shaped by by the Java wars.” One too many “by”s.

Regarding Laurie White’s comment about clarifying whether you are biased (which I got, but I’ve been there), maybe you could just change the beginning of this sentence from “So my thinking of static typing was shaped…” to “So my bias against static typing arose from…”?

2010-08-31
152TYPO

The = sign after the inform method definition is superfluous and will confuse my students (e.g., why is it here but not on turnRight or turnLeft? or why is it on direction without braces, but here with braces?). It is repeated on page 153.

2010-08-31
153DEFER

Every segment of the Compass class used in the explanation is preceded by the Download shaded box, cluttering the discussion. In other places, it only appears when the entire program is shown (which is easier to read).

2010-09-01Here, it's a longer program and I'm using callouts in a file. The reader will be able to find the callouts within the file. At this stage, I'm going to leave this like it is, but I agree, it might have been good to be more consistent, so I'll mark this as a fix for another release of the book, if there's enough readership to merit a second release.
156TYPO

Very last sentence. “…our trait called Nice with a method called Greet…” Should be “greet” (lowercase).

2010-08-31
168TYPO

The alternate syntax, “list reverse” (vs. list.reverse), is accidentally introduced in the middle of reviewing the List methods (first example in blue on page). I say “accidentally” because it is not explained and is not consistent with any of the other examples.

2010-08-31
169DEFER

While not incorrect, it would be clearer at the bottom of page 169 (and in the description at the top of page 170) if you used something other than “i” for the element value in your fold left sum example. The variable “i” is often sed as a loop counter and since your list values are 1, 2, 3, one could easily think you are getting passed an index rather than the list values (despite indices normally starting at 0). You will note that you use the name “value” for this same variable when you invoke foldLeft near the bottom of page 170. It would be more consistent, as well as clearer, to also use “value” for the similar example at the bottom of page 169.

2010-09-01
172OK

“Caribean” throughout is spelled “Caribbean” (and on to page 173).

2010-08-31
173TYPO

Last paragraph: “Next to each, we have some code blocks beside those chores.” is redundant. Should be “Next to each, we have some code blocks.” or “We have some code blocks beside those chores.”

2010-08-31
173TYPO

Last paragraph: “Scala executes the first code to match…” What does “the first code” mean? Do you mean “the first code block” or “the first case” or “the code block associated with the first case”?

2010-08-31
179TYPO

Top code segment is supposed to be getPageSizeConcurrently, not getPageSizeSequentially. [Or the text above and below it is incorrect…]

2010-08-31
179TYPO

2nd paragraph: “Next, we simply receive five messages…” should be “four messages”.

2010-08-31
181TYPO

First bonus problem at top: “Form example, sizer for ‘google.com’…” should be “For example…”.

2010-08-31
181TYPO

2nd bonus problem: “At the end of the sizer problem, there is a sleep command.” What are you referring to here? There is no sleep in the text nor in the source file itself.

2010-08-31
188TYPO

3rd paragraph, 2nd sentence: “Error handling is the least
understood parts of the language…” should be “part” or “one of the least”.

2010-09-02
188TYPO

5th para, last sentence: “I think it would be really nice to go back the roots of Erlang” should be “…back to the roots…”.

2010-09-01
190TYPO

Under “Getting Started”, you say you are using version 5.7.3, but the output when you start Erlang (shown below it) says 5.4.13. This seems to be the emulator version, not necessarily the language version. On the Erlang website, the versions are named R#, as in R14 (the latest).

2010-09-02
203TYPO

2nd line of map definition near bottom of page:
map(F, [] -> []. is missing the closing parenthesis [should be map(F, []) -> [].].

2010-09-13
224OK

The “Core Weaknesses” heading is one paragraph too late as the paragraph preceding it introduces the weaknesses.

2010-09-13
230SUGGEST

Paragraph after (- 8 1 2) example (I would call it 4th): “Or, if you’d like to see the Clojure equivalent, it is (- (- 8 1) 2) and (/ (/ 8 2) 2).”

I find this very confusing because frankly we just saw the Clojure equivalents and they were (- 8 1 2) and (/ 8 2 2). I think you are trying to say the Clojure equivalent of forcing order of evaluation with parentheses. I am not sure how to say this simply, but just calling it “the Clojure equivalent” is confusing.

2010-09-13
237SUGGEST

2nd paragraph: “You might think we’ve encountered a syntactic inconsistency.” Perhaps if I wasn’t paying attention. We just did this with vectors and sets. The place to say this is the first time this construct occurs, i.e., with vectors on page 234. Here it is just confusing.

2010-09-13
240TYPO

First defn center is missing a ‘]’: “(defn center [[_ [_ c]] c)” should be “(defn center [[_ [_ c]]] c)”

2010-09-13
241TYPO

3rd para: “We can compute the count of one word like this:” should be “…length of one word…”

2010-09-13
241TYPO

5th paragraph, last sentence: “…to compute a list having twice the counts of person names…” again should be “…lengths of person names…” [English meaning of count of names is how many names you have, not their lengths]

2010-09-13
241TYPO

Formatting error with shorter form of anonymous function: “#(* 2 (count %)) people)” is in green (instead of blue)

2010-10-29Prags? This is the commenting error I mentioned earlier.
241TYPO

Last paragraph, 1st sentence: “…give you convenience and leverage, to create…” should not have a comma.

2010-09-13
242TYPO

Same formatting problem with second filter example using anonymous function: “#(< % 3) v)” is in green instead of blue.

2010-10-29prags?
244TYPO

4th paragraph (including incomplete), 6th sentence: “Older
Lisps use parenthesis for everything.” should be “…parentheses…”

2010-09-13
245TYPO

Extra bullet with no text at end of “Do:” subsection of “Day 1 Self-Study”.

2010-10-03
246TYPO

First example, the definition of size is incorrect. The else part of the if is “(size (inc (rest v)))” when it should be “(inc (size (rest v)))”.

2010-09-13
246ERROR

May just be a typo, but just before the first example (defining size) - in fact the 2nd sentence of the 1st paragraph of the “Recursion…” section, it says “…to evaluate the size of a list:” But, in fact, the code only works for a vector, not a list, and that is the example given. On a list, it gives a java.lang.ClassCastException.

2010-09-13
249SUGGEST

2nd example from the bottom of the page (first sort): It would be more impressive if the list you passed to sort, [1 2 3 4] wasn’t already sorted. You would use, for example, [3 2 4 1].

2010-09-13
250ERROR

3rd paragraph under “Finite Sequences with range”: “You don’t have to specify the lower bound:”. While this is true for your example, you must specify a lower bound if you wish to use an increment other than 1. I suggest a simple rephrasing: “You don’t have to specify the lower bound if there is no increment:”

2010-09-13
251OK

Interpose example (3rd example): Why did we only get 3 elements of the sequence rather than the 5 we requested? I think it is important to point this out and explain the returned “and:”s are included in the count of 5. So if we wanted 5 elements from the innermost cycle, we would have to take 9. This is not at all obvious.

2010-09-13
251OK

Paragraph after interleave example, 3rd sentence: “…even numbers are (0 1 0 1 0 1 0 1 0 1), and odd numbers are (0 1 2 0 1 2 0 1 2 0).” This is quite confusing as 1 in the first sequence is not even and neither 0 nor 2 are odd in the second. If you mean pulling the even-numbered indices, well that assumes you are starting at 0 (but mightn’t we be starting at 1, as in the 1st?). It would be much clearer to explicitly state “If you pull alternate elements out starting with the first, you get …, and if you start with the second, you get…” or something like that.

2010-09-13
252ERROR

5th paragraph (inc. partial at top): “Or we can grab number 500, like this:” It is certainly index 500, but it is the 501st number in the sequence as nth counts from 0. I do not believe there is clear agreement whether the first Fibonacci number is fib(0) or fib(1) [I have seen it both ways in many different places], so it would be safer, and more accurate, to say the 501st Fibonacci number.

2010-09-13
254TYPO

5th paragraph (including partial), last sentence: “For example, (directions 3) returns :west.” This sentence is misplaced; it belongs after the 1st sentence in the paragraph.

2010-09-13
255TYPO

2nd example missing “.” after SimpleCompass: “(def c (SimpleCompass 0))” should be “(def c (SimpleCompass. 0))”

2010-09-13
255TYPO

3rd example: seems we are back to Ruby formatting:
“c ; original compass unchanged
”=> #:SimpleCompass{:bearing 0}"

instead of:
user=> c ; original compass unchanged
#:SimpleCompass{:bearing 0}

[by the way, when I do this I am not in the user namespace, but the tate.compass namespace, so it does not say “user=>” as you show throughout, but “tate.compass=>”.

2010-10-29prags: formatting # is a comment again
258SUGGEST

Replace the 3rd problem under “Do:” (in “Day 2 Self Study”) as you already walked through the solution on page 252.

2010-09-13
144SUGGEST

You write:

—- 8< —-
Strictly speaking, a functional
language has these characteristics: […].
Strictly speaking, Scala is not a pure functional programming language […]
—- 8< —-

There’s a double “Strictly speaking” in use. You might want to get rid of one of them (I’d vote for the first one).

Cheers,
Gina

2010-09-13
260TYPO

4th example (“@movie”): Shows the original string “Star Wars” rather than the modified string “Star Wars: The Revenge of the Sith”.

2010-09-13
262TYPO

Very last sentence: “Next, we’ll define an agent that has an initial value of tribbles:” should say something like “an agent named tribbles with an initial value of one.”

2010-09-13
263TYPO

4th example: @tribbles is suddenly 16. When we last saw it (previous example just above), it was only 2. How did it become 16?

2010-09-13
263ERROR

Last sentence of 3rd paragraph: “(Remember, in Io, the future mutated to the value after the computation
was complete.)” This is at odds with what you say at the bottom of page 93, and indeed with my limited experience in Io. Futures in Io do indeed block if necessary just as they do in Clojure. This statement suggests they do not.

2010-09-13
270TYPO

3rd sentence under “Accessibility”: “Clojure places tremendous demands on developer” should be “the developer” or “developers”.

2010-09-13
291TYPO

3rd problem of “Do:” under “Day 1 Self-Study”: “Note
that you should include only one of (green, blue) and (blue, green).” “green” is not one of the colors in the problem, so this is confusing. Change to, for example, “…(red, blue) and (blue, red).”

2010-09-13
308TYPO

top of page, first line: ‘Understanding Mondads’ should be ‘Understanding Monads’

2010-09-13
264TYPO

Last paragraph, 1st sentence: “These both change the entire atom…” You have only discussed one way to change the atom, “reset!” Later in the same sentence, “…the preferred usage is to use a function…” I am pretty sure “reset!” is a function. Do you mean user-supplied function?

2010-09-13
293ERROR

Last example at the bottom of the page: “foldl1 (\\x carryOver -> carryOver + x) 0 [1 .. 10]”

This is not correct and will not compile. The correct form is one of the following (but only the first matches the text that follows):
“foldl (\\x carryOver -> carryOver + x) 0 [1 .. 10]”
“foldl1 (\\x carryOver -> carryOver + x) [1 .. 10]”

2010-09-13
296OK

3rd example, 1st line: “take 5 (lazyFib 0 1)” should be “take 5 (lazyFib 1 1)”

2010-09-13I'm going to leave this as it is. Fib starts at 1, 1, etc.
296TYPO

3rd example, 5th line has the same problem: “take 5 (drop 20 (lazyFib 0 1))” should be “take 5 (drop 20 (lazyFib 1 1))”

2010-09-13
300TYPO

Last problem at the bottom: “Use partially applied functions to define a function that will return half of a number and append \
to the end of any string.” should read “…and another that will append \
…” or something like that. The way it reads it sounds like one function to do these two disparate things.

2010-09-13
301TYPO

The last 3 bulleted problems form a sequence that is not at all clear unless you read it a few times. These should be grouped together or otherwise connected with phrases (e.g., the second could say, “Add line numbers to the lines of text generated above.” But it would be better to group them together under one heading.

2010-09-13
297ERROR

2nd to last paragraph (just above “An Interview with Simon Peyton-Jones”): This paragraph is very confusing and contradicts earlier statements. In Haskell, “f . g x” is shorthand for f(g x). Thus, g is evaluated first and its result is passed on to f to be evaluated - just as you describe it in the paragraph above this. In this paragraph, however, your example says that “f . g x” is shorthand for g(f x), i.e. that f [or “invert” in your example] is evaluated first, which is not the case. While it is true that f . g sometimes is the same as g . f, more often they are not the same. If you care to invert, flip vertically, flip horizontally, and then move to the right, the correct code is “(shiftRight 20) . flipHorizontally . flipVertically . invert image”. Suggesting otherwise is confusing. Yes, in this case, it does seem the order does not affect the results (though I am doubtful that is true of shiftRight), but then you must come right out and say that when you do not particularly care about the order because the functions are symmetric, then you can rearrange it this way - but then do not also suggest that Haskell will somehow change its execution order from left to right in the rearranged order.

2010-09-13
302TYPO

At end of top example, after last “abc”, it is missing the line: “it :: [Char]”.

2010-09-13
304TYPO

Last paragraph: “Let’s bring back the definition of
one of our functions:” This is the first time we have seen the “backwards” function, so we are not bringing it back.

2010-09-13
305TYPO

2nd example (“:load tree.hs”): Missing final line “Leaf 1”.

2010-09-13
305TYPO

4th example (building more complex trees): Missing final line of output: “Children[Leaf 1,Children [Leaf 2,Leaf 3]]”

2010-09-13
308TYPO

Very top of page: “standing Mondads has some good practical examples.” should be “Monads”

2010-09-13
284ERROR

Starting at the top of page 284 and continuing through the chapter (the last usage is at the top of page 309), the term “functional composition” is repeatedly used. However, the correct term both in Haskell and mathematics is “function composition”.

2010-09-13
309TYPO

Second bullet under “Components of a Monad”, last sentence: “…return wraps up a function into a monand.” should be “monad”

2010-09-13
310SUGGEST

After carefully explaining we’ll use the bind function named >>=, you use one named >> in the example. I suggest either changing this to use >>= or explaining why >> was used.

2010-09-13
310SUGGEST

“rtn” has the same issue as “>>==” - after telling us we would call it “return”, you call it “rtn” Please explain or use “return”. If the intent is to show us you can call them anything you want, then say so and also explain the convention is to use the names you gave earlier.

2010-09-13
311ERROR

5th paragraph, 2nd sentence: “In GHCI, you must separate lines with semicolons and include the body of do expressions, and let expressions therein, within braces.” It’s not braces alone, but “:{” and “}:” on separate lines.

2010-09-13
311TYPO

Very last sentence: “The identity monad just parrots back the thing you put into it. We used it to convert…” We did not use the Identity (capital-I) monad. Perhaps you are referring to the drunken-monad, which is an identity of sorts, but it was not called that. Again, at the top of page 313, “So far, we’ve seen the Identity monad…” But we haven’t.

2010-09-13
144TYPO

Last paragraph:
(With most object-oriented languages, a typical getter would
break that rule.)

From my perspective its a setter that breaks the rule. If you call a getter on an object in the absence of any mutators it always returns the same value. The setter is the mutator in the OO paradigm, yes ?

2010-09-13
151ERROR

shouldn’t args.each {|arg| println(“arg”) }
be args.each {|arg| println(“#{arg}”) }

2010-09-13
297TYPO

2nd to last paragraph (just above “An Interview with Simon Peyton-Jones”): “invert . flipVertically . flipHorizontally . (shiftRight 20) image” should be “(invert . flipVertically . flipHorizontally . (shiftRight 20)) image”. [Parentheses around composition are required (tested on GHC).]

2010-09-13
322TYPO

3rd paragraph of “Changing Paradigms”, 3rd sentence: “…that should have been solved in the space.” At least one word is before “space”: “…in the language space”? “…in the Java language”?

2010-09-13
324ERROR

4th sentence of “Futures”: “We also supported futures in Clojure, but the Io approach to futures was different.” How was it different? Not in the ways described here. Both return immediately, both block if we try to access it before the result is available, and both morph into a result when the result becomes available.

2010-09-13
326TYPO

Last paragraph under “Matching”: “The tail-optimized loop call matched a process ID (From) followed by a word…” While there was a version of this in the Erlang chapter that matched a process ID and word (pg. 217), this one is not it. I also find “tail-optimized loop call” a bit misleading as this is not a “call”, it is a function and it is not “tail-optimized”, it is “tail-recursion-optimized”, but that is not really important in this section.

2010-09-13
56TYPO

There’s something wrong with the beginning of footnote 4: “DSLsc om let you tailor a language …”

2010-09-13
59TYPO

Bottom of page 59, the word ‘just’: “A method is an object, jut like any other type of object.” should read “A method is an object, just like any other type of object.”

2010-10-03
58TYPO

First line : So, the acts_as_macro code …
Isn’t it acts_as_csv macro as in the previous paragraph ?

2010-10-07
105ERROR

Ruby-style comments (starting with #) in the code examples are not accepted.
Like old Borland’s Turbo Prolog, GNU Prolog accpts /* C-style comments*/.

with :
#—-
# Excerpted from “Seven Languages in Seven Weeks”, …
#—-

| ?- [‘food.pl’].
compiling E:/Userdata/Devl/Seven languages in seven weeks/Prolog/GNU-Prolog/food.pl for byte code…
E:/Userdata/Devl/Seven languages …/food.pl:2:1: syntax error: . or operator expected after expression
E:/Userdata/Devl/Seven languages …/food.pl:4:3: syntax error: . or operator expected after expression
E:/Userdata/Devl/Seven languages …/food.pl:4:37: syntax error: . or operator expected after expression
…
7 error(s)
compilation failed

but with :
/*#—-
# Excerpted from “Seven Languages in Seven Weeks”, …
#—-*/

| ?- [‘food.pl’].
compiling E:/Userdata/Devl/Seven languages in seven weeks/Prolog/GNU-Prolog/food.pl for byte code…
E:/Userdata/Devl/Seven languages …/food.pl compiled, 12 lines read - 1617 bytes written, 20 ms

(10 ms) yes

2010-12-13
165DEFER

The numbers “zero”, “one”, “two”, etc. are cardinal numbers not ordinal numbers.

2011-07-31
193ERROR

There appears to be an example missing after “Here’s a little surprise:”

2010-10-06
209DEFER

Near the top of the page, “The second argument must be a list.” However, example 15 just above shows a second argument not a list, and the result is an improper list.

2011-07-31
213TYPO

“spawning a message” should be “spawning a process”

2010-10-07
215TYPO

Should “node@Pid” actually be “Pid@node”?

2010-10-07
216DEFER

In the snippet in “Receiving Synchronously”, probably should use From instead of Pid to match the completed example on the next page.

2011-07-31
249ERROR

In the example defn size, the last line should be “(inc (size (rest v)))))” instead of “(size (inc (rest …”

2010-10-06
251DEFER

Instead of saying “The result is not a list.” perhaps “The result of (rest [1 2 3]) is not a list.” Also, the example doesn’t actually show that the result is not a list, despite appearances.

2011-07-31
255TYPO

First example with “((iterate fib-pair” has an extra opening parenthesis

2010-10-07
308ERROR

The stagger=1 and crawl=2 description in the first drunken pirate description doesn’t match the later implementation of “stagger d = d + 2” and “crawl d = d + 1”.

2010-10-07
309DEFER

When you want to translate “stagger(crawl(x))” into something else, there seem to be too many “(x)”. Should it be something like “(stagger . crawl)(x)” which certainly looks more like functional composition? And the statement “That’s a monad” seems out of place because monads must be more than just functional composition.

2011-07-31Good comments, and in the next edition, I will clarify. For the identity monad (the one we're presenting in the Drunken Pirate), we effectively have functional composition. In fact, if you look at the wrap and bind, that's exactly what's going on. As the monads get more complex, the composition of functions also gets more complex, but the chaining of the elements of the monad does not. \n \nI will clarify in the next edition. Thanks for the comment.
119DEFER

5th example | ?- [] = [].
To be consistent with the other examples, I would give the answer “yes” :
| ?- [] = [].

yes

2011-07-31
119DEFER

The paragraph after the examples says : “The last two examples are interesting.” talking about [2, 2, 3] = [X, X, Z]. and [1, 2, 3] = [X, X, Z]. But they are not the last two because of [] = []. which comes last.

2011-07-31
125TYPO

5th bullet So, we know Tail2-C is [3]… Instead of :
Tail2-C is [3], which means [2|Tail2-2] is [2, 3], and finally [1|Tail2] is [1, 2, 3]. What is [1, 2, 3]?
I would say :
Tail2-C is [3], which means [2|Tail2-B] is [2, 3], and finally [1|Tail2-A] is [1, 2, 3]. What is [1, 2, 3].
that is three changes :
[2|Tail2-2] -> [2|Tail2-B]
[1|Tail2] -> [1|Tail2-A]
? -> .

2010-12-13
124DEFER

The second paragraph says “For concatenate(List1, List2, List3), we break …”. To be consistent with this 1-2-3 naming, I would change the final prolog/concat.pl example from :
concatenate([Head|Tail1], List, [Head|Tail2]) :-
concatenate(Tail1, List, Tail2).
to :
concatenate([Head|Tail1], List2, [Head|Tail3]) :-
concatenate(Tail1, List2, Tail3).
(Idea from a Turbo Prolog book :
append([], List, List).
append([X|List1], List2, [X|List3]) :- append(List1, List2, List3).)

2011-07-31Good catch. Will fix the next time around, so we don't inadvertantly introduce errors.
255SUGGEST

“iterate takes a function and a starting value. iterate then applies the function to the starting value repeatedly.”

I think that the second sentence needs a clarification. Doesn’t iterate apply the function to the starting value initially and then the return value of the function? Not sure how that means the sentence should be reworked though.

2010-12-13
259TYPO

“With defrecord and protocol, Clojure offers the ability to build native code for the JVM, without Java.”

Should be “With defrecord and defprotocol…”

2010-12-13
261TYPO

“Next, we spent some time implementing types. With defrecord and pro- tocols, we were able to implement types that were full citizens on the JVM.”

Should be “…defrecord and defprotocol…”

2010-12-13
266ERROR

Isn’t this defining and agent with an initial value of 1 and naming it tribbles?

Next, we’ll define an agent that has an initial value of tribbles:
user=> (def tribbles (agent 1))
#’user/tribbles

2010-12-13
264TYPO

The output of the last REPL statement doesn’t seem to reflect the previous change, hence the comment doesn’t make sense. There has been no change to the value returned by @movie.

user=> (dosync (alter movie str “: The Revenge of the Sith”))
“Star Wars: The Revenge of the Sith”

You can see that the reference changed:
user=> @movie “Star Wars”

2010-12-13
127TYPO

mispelled sudoku as sodoku

2010-12-13
244ERROR

‘count’ is not the higher order function. ‘map’ is. map is a function that takes a function as an argument. thus it is higher order.

2010-12-13
34ERROR

“As always,you can find the answers in the back of the book”. At least in the ebook, I could not find any “Answers” section.

2010-12-13
287ERROR

Prelude> foldl1 (+) [1 .. 3]
6

This raises an error when run in ghci, I think you need to define the 0 value for the accumulator. It should be
Prelude> foldl1 (+) 0 [1 .. 3]
6

2010-12-13
68DEFER

At the start of the Lists and Maps section the list( … ) notation is introduced as a way to create the toDos list, and then mentioned as a short cut way of representing a list.

After being told that List was the prototype for lists I was expecting something like:

toDos = List clone
toDos append(“find my car”, … )

and then have the short-cut introduced.

Was skipping List clone intentional?

2011-07-31
22OK

Middle of page, paragraph starting, “This is not too complicated”; code showing object_id for ‘string’ has typo. Value returned is not the same for the two invocations.

2010-12-13
14TYPO

The 8th line from the bottom of the second code block starts with a “?>” instead of a “>>” and the line is not bolded. This is inconsistent with the rest of the code in that section.

2010-12-13
35TYPO

“Unlike Java and C#.[…]”

The correct punctuation should be a comma ( , ) rather than a dot ( . ).

2010-12-13
173OK

This code doesn’t work:

def getPageSize(url : String) = Source.fromURL(url).mkString.length

but this which I figured out from the API on Source.fromURL does work:

def getPageSize(url : String) = Source.fromURL(new java.net.URL (url)).mkString.length

The error was “type mismatch; found: String required: java.net.URL”.
I am using Scala v2.8.0.RC1. The API makes it sound like the shorter version should work but only the suggestion offered in the description works for me - “same as fromURL(new URL (s))”.

2011-02-03This code works fine for me. The file runs just as it is in the text.
29OK

In the listing in the middle of the page, several examples are given of how even numbers are objects with associated methods. The second example, “4 + 4”, was probably intended to be “4.+ 4”. Both work, but the first is a non sequitur while the second reinforces the notion that “+” is a method of “4”.

2010-12-13I can see how you read it that way, but am inclined to leave it as it is.
274ERROR

The first interactive example on the page should read:

Prelude> foldl (+) 0 [1 .. 3]

(The ‘0’ as second argument to foldl is missing).

2010-12-13
100ERROR

loading list_math.pl from the prolog files folder of the code download results the following output:
compiling /home/xxx/prolog/list_math.pl for byte code…
/home/xxx/prolog/list_math.pl:10: warning: singleton variables [Head] for count/2
/home/xxx/prolog/list_math.pl compiled, 14 lines read - 1603 bytes written, 18 ms

Is there an issue?

2010-12-13
96OK

The respose to the sequence:
| ?- ancestor(john_boy_sr, john_boy_jr).
true?

Is Yes, not no as the book states.

2011-02-03The first true is the answer; the 'no' after the 'true' means there are no more results.
98SUGGEST

When loading a Prolog file using gprolog, it is not necessary to include the extension of the file (.pl). So, “[‘myfile’]”. will work just as fine as “[‘myfile.pl’]”.

2010-12-13
39SUGGEST

CONTEXT: “If you pass in a :profession of :lawyer, you will get something different. The result is not fully true, but it is almost just as good, because the system will evaluate it as true. Notice that you didn’t have to type in the braces. These braces are optional for the last parameter of a function.”
I found this confusing: fine without braces, but when providing braces there is an error (Ruby 1.8.7):
irb(main):073:0> tell_the_truth {:profession => :lawyer}
SyntaxError: compile error
(irb):73: syntax error, unexpected tASSOC, expecting ‘}’
tell_the_truth {:profession => :lawyer}
^
from (irb):73
from ♥:0

2010-12-13Good suggestion. You actually have to provide parens if you provide braces. I will add the parens to the call to keep things clear. \n \n
245TYPO

First sentence in Changing a Sequence section:

“The sequence library has a number of sequences that transform se- quences…” should be “The sequence library has a number of functions that transform se- quences….”

2010-12-14
245SUGGEST

In the Tests section, I read, “These take a sequence and a test function and return a boolean.” Yet, all the predicate functions take a test function and sequence. Note the order. Change the above sentence to: “These take a test function and a sequence and return a boolean.”

2010-12-14
47ERROR

“(If you don’t specify a value, inject will use the first value in the collection.)”
Rather, I found that it used 0 - as in:
a = [5, 1]
=> [5, 1]
a.inject {|sum, i| sum + i} # initial value seems to be 0
=> 6
a.inject(5) {|sum, i| sum + i} # simulate first value of a
=> 11

2011-03-05
266ERROR

Wrong description of zip function(ll. 11-12).

Maybe below is correct result.
Prelude> zip “kirk” “spock”
[(‘k’,‘s’),(‘i’,‘p’),(‘r’,‘o’),(‘k’,‘c’)]
Prelude> zip [“kirk”] [“spock”]
[(“kirk”,“spock”)]

2011-03-05
48TYPO

Context “Let the initializer accept a nested structure with hashes and arrays.” and the given test case seems to be all hashes in my version: “{’grandpa’ => { ’dad’ => {’child 1’ => {}…”.

This was interesting, and I learned how to get hashes out of a hash using “nested.merge(nested) do |n, o|” and so on, as a result.

2011-03-05
52DEFER

chomp.split(‘, ’) # with a space after the separating comma, each line from the file is preserved with literal separators, as in: [“id|forename|surname|postcode”] for a header (I used | for a separator instead of ,)

with chomp.split(‘,’) # without a space after the separator character, each line is split into fields, as in: [“id”, “forename”, “surname”, “postcode”] and the separator character is omitted.

I found the second form above more useful.

2011-03-05Test file has a space after headings. The code could probably be more defensive, but works as is. \n \nGood eye. Will change this in next edition, because code changes are so dangerous at this point. \n-bt
52DEFER

If your fields in the CSV text file are indeed separated by comma-space as in: id, forename, surname, postcode then the code as provided is right.

2011-03-05
116SUGGEST

The function “append” does not compute permutations (which would be different sequences) of a list, but is able to compute different “splits” of a list (retaining the order).

2011-03-05
241SUGGEST

CLR has a footnote the second time its mentioned, but not on the first (bottom of page 239 in the PDF). I went to look it up the first time, just to find it explained a bit later :)

2011-03-05I'm going to mark this as fixed. It will be if we can keep the indexing and page breaks intact. If not, please accept my apology, and we'll try to get to this in the next release.
305SUGGEST

You write “From that point, our password cracker is easy.”, suggesting that this example was introduced before (making it “ours”). That’s not the case, its the first mention of the password functionality.

2011-07-31In the last printing, it was changed from "our" to "a" meaning that it's easy to build a brute force password cracker.
157DEFER

The act() method of class Kid uses ‘react’ but the only way I can get this code to produce the output as listed on page 158 (using 2.8.1-Final) is by changing ‘react’ to ‘receive’

2011-03-05This code runs fine in my environment. I'll check it again in time for the next edition, when I update the code in the book. \n \n-bt
79OK

In the third paragraph, you write “The call method gives you access…” Do you mean “The call object gives you access…” or “The object bound to the variable call gives you access…”?

2011-03-05It is definitely confusing, but call is indeed a method. The method is used to return the metadata around a message: parameters, name, etc. \n \nI am perhaps being a bit loose with the terminology method and message. Both are used interchangeably, though a message is the vehicle for invoking a message. I'm inclined to leave this line as it is to keep the book consistent.
35ERROR

On page 35, you say ’As always, you can find the answers in the back of the book." However the answers are not there. In the forum discussion, you say you decided to not include the answers. So you should remove this reference to answers that actually do not exist.

2011-03-05
238OK

The definition of higher-order functions is incorrect. A higher-order function is one that takes functions as arguments. ‘map’ is a higher-order function. ‘count’ is not. “Anonymous function” is an independent concept.

2011-03-05Lots of definitions out there. In math, a higher order function is one that takes functions as arguments, or returns functions (basically functions that produce or consume functions). For one example of this description in the programming language context, check out various Haskell sources, including \n \n"http://www.haskell.org/haskellwiki/Higher_order_function". \n \nAnonymous functions are examples of higher order functions, as they are usually passed as arguments. I am inclined to use it as is.
47TYPO

The code block following “>> a.inject(0)” up to “?>end”
is not formatted as code but as irb output.

2011-03-05
61TYPO

“Did you catch that the optional argument is actually the third one?” Well, no, it’s the fourth, unless you’re counting from zero :)

1. counter name
2. first val
3. last val
4. optional increment
5. message

2011-03-05
64ERROR

In examples of Io messages, at bottom of page it says: “So, the deliver method is the object that sent the message.”
But the output shows the sender was the mailer object, not its deliver method.

That would be consistent with the objects introspection section of the io programming guide, which says that “call sender” returns “locals object of caller”. (IIUC this locals object is “self” in the method or block that sent the message.)

2011-03-05
54DEFER

Entering

elvis asObject

returns the following error message:

Exception: Map does not respond to ‘asObject’
————-
Map asObject Command Line 1

2011-03-05This code works on the mac, Io version specified in the book. Good catch though. Going to mark this next edition, as we'll update the versions of all languages at that time.
xvTYPO

<"We must insist that the next programmer we hire has read all of ‘A la recherche du temps perdu.“‘> The single quote should come before the double quote mark at the end ’” not "’

2011-03-05
121TYPO

In the two places of the third paragrah, “sodoku” is believed to be a misspelled word of “sudoku.”

… of the form sodoku(Puzzle, Solution). Our users can provide a puzzle as a list, substituting under-scores for unknown numbers, like this:
sodoku([,, 2, 3,
,, ,,
,, ,,
3, 4, ,],
Solution).

2011-07-30
279ERROR

The code sample <‘zip “kirk” “spock”> does not return <[(’kirk’,‘spock’)]> (given that those are single quotes, that’s not even a valid Haskell value) but returns <[(‘k’,‘s’),(‘i’,‘p’),(‘r’,‘o’),(‘k’,‘c’)]>. As we can see here; zip never builds , it always takes two lists (as in the list of chars above), despite the implication shortly thereafter that it can take other arguments: (note “also”).

2011-07-30
193DEFER

I think that if another_fib is an implementation of Fibonacci series, another_fib(0) must return 0 not 1.

2011-07-31I think you are correct, but since this hits both the book and the code example, I am going to wait to fix this problem until the next release. \n \nGood catch.
46ERROR

a and b are referenced in the first paragraph, but don’t appear in the preceding text - the expression ‘a <=> b’ is missing.

2011-07-29
100ERROR

Instead of

| ?- [‘code/prolog/food’].

it should read

| ?- [‘food’].

Otherwise gprolog cannot load the file (assuming you have donloaded it to CWD like the previous prolog script).

2011-07-30
116DEFER

In the first line of code of ‘optimized_queens.pl’:

valid_queen((Row, Col)) :- member(Col, [1,2,3,4,5,6,7,8]).

should be:

valid_queen((_, Col)) :- member(Col, [1,2,3,4,5,6,7,8]).

It works okay but gives a warning.

2011-07-31Good catch. I am going to leave this as is. I will mark it as next release.
238DEFER

The Haskell wiki is correct. It is the function that takes a function as an argument that is higher order not the function that is the argument (just because it is passed as an argument). An anonymous function may or may not be higher order. The two concepts are independent.

2011-07-31
90DEFER

An example in Futures chapter, which fetches an url, raises an error like follows:

==> Error_0x8c9abc0:
location = “/usr/local/lib/io/addons/Socket/io/URL.io:216”
message = “max redirects”

Error_0x8c9abc0:
location = “/usr/local/lib/io/addons/Socket/io/URL.io:216”
message = “max redirects”

2011-07-31I'm going to wait to address this until the next release.
305TYPO

The second list is wrongly named in “We took x from a list of xs, and we took y from a list of xy.”; its name in the “cartesian” function is “ys”, not “xy”.

2011-07-30
149TYPO

“The class has a constructor with one parameter, firstName […]”

In the summary (quote shown above) you use “firstName” but in the code sample, you use “first_name”

2011-07-30
31DEFER

In the while/until example the initialization of x is missing (e.g. x=0), which will cause an error (NoMethodError: undefined method `<’ for nil:NilClass). If you’ve continued coding from the last example you’ll probably be fine (since x will be set to 4), but if you’ve startet a new irb-session it will cause this error.

2011-07-31Good point. I'm going to mark this as next-edition so I don't renumber the pages, and renumber the example. I had intended this to be a continuation from the previous example.
31ERROR

[The paperback book identifies itself as “P3.0 printing, March 2011 Version: 2011-3-28”. That isn’t an option on this form, so I picked the only other P3.0 option]

The description of Ruby’s Array::inject method seems to be incorrect. Interestingly, it was changed from the 2.0 version (errata report #46026).

The text in the book is currently: “(If you don’t specify a value, inject will use the value 0 in the collection.)”

This isn’t correct, it instead uses the initial value of the collection (as was originally written), but then starts execution at the second element (perhaps this second fact was the actual correction the previous errata wanted).

Some code and output that shows the situation(Ruby 1.9):

0>a = [5,3,4,1]
0>a.inject do |product, i|
1> puts “p: #{product} i: #{i}”
1> product * i>end
p: 5 i: 3
p: 15 i: 4
p: 60 i: 1
=> 60

as opposed to:

0>a = [5,3,4,1]
0>a.inject(0) do |product, i|
1> puts “p: #{product} i: #{i}”
1> product * i>end
p: 0 i: 5
p: 0 i: 3
p: 0 i: 4
p: 0 i: 1
=> 0

or:

0>a = [5,3,4,1]
0>a.inject(1) do |product, i|
1> puts “p: #{product} i: #{i}”
1> product * i>end
p: 1 i: 5
p: 5 i: 3
p: 15 i: 4
p: 60 i: 1
=> 60

Regards,

2011-07-29Yeah... that's broken. Will fix.
102OK

The problem of painting a map with Prolog is interesting, but i didn’t feel comfortable having to “tell” prolog that blue is different from green, for example. It should “know” that. Moreover, this approach makes the size of the KB grow exponentially with the number of colors.

After some tinkering, i got this alternative:

color(red).
color(green).
color(blue).

solution( color( ‘Alabama’, A ),
color( ‘Mississipi’, M ),
color( ‘Georgia’, G ),
color( ‘Tennessee’, T ),
color( ‘Florida’, F ) ) :-
color(A), color(M), color(G), color(T), color(F),
\\, \\(M = A),
\\, \\(A = M), \\, \\(A = F),
\\, \\(G = T)
.

/* consult, then do solution(A,B,C,D,E) */

I’m still not 100% happy with it. It seems to me that one should be able to say
touching( Mississipi, Tennesee )
touching( Mississipi, Alabama )
etc
and have a rule that says “touching states must have different colors.” However, i haven’t been able to figure out how to express that in a way that works, so the solution above is the best i can do at the moment.

2011-07-31This is an interesting solution to the example, but my example illustrates a point: the simplicity of the example is striking, and it teaches the concepts I want to teach. I like your example, but I am going to leave the text as it is.
65TYPO

the postOffice messageTarget returns Object_0x1004ce658. This should be the same as Object_0x100444b38 that was the result of postOffice := Object clone on the previous page.

2011-07-31
226DEFER

It may be interesting to know that “repl” stands for Read-Eval-Print Loop, and that’s the common name for the Lisp/Scheme prompt as well as a precise description of what it’s doing. Each one of these (Read, Eval, Print, Loop) is a function: (loop (print (eval (read)))): read a line of input from the console, evaluate it, print the result back to the console, and repeat.

2011-07-31Interesting note. Will add it to the next edition to preserve the page breaks and the index.
138TYPO

In the following sentence, there should be a space between ‘Nice’ and ‘trait’. Also, ‘trait’ should not be formatted as code.

“The final element, a class called Character, mixes in the Nicetrait.”

2011-07-30
152TYPO

Technically speaking, in the following sentence ‘empty’ should be ‘isEmpty’ and ‘first’ should be ‘head’.

“We also used count, empty, and first methods for obvious purposes.”

2011-07-30
193DEFER

Immediately after mentioning Erlang is tail recursion optimized, two recursive examples are given - factorial and fibonacci. But neither of them are implemented in a tail recursive fashion. This could be confusing.

Good catch. I will revise these in next edition, ok? \n
42ERROR

Fixnum is not derived from Class. It is an instance of Class.

2012-01-21
42DEFER

Figure 2.1 is correct but to make it consistent with the code you show, the three blue boxes on the left should be moved down with the left arrow coming from Fixnum, not Numeric. Then add an Object box above Numeric with an up arrow showing the inheritance.

Good catch. Changes like this are a little bit dangerous and expensive, so I am going to live with this problem and fix it in the next edition, ok?
43OK

This is a minor coding error, but in the “ruby/tree.rb” code, the reference to children is missing ""

>>>Currently in PDF<<<<
def visit_all(&block)
visit &block
children.each {|c| c.visit_all &block}
end
>>>>>>>>>>>>>>>>>

>>>>Should be<<<<<<<
def visit_all(&block)
visit &block
@children.each {|c| c.visit_all &block}
end
>>>>>>>>>>>>>>>>>

Thanks

2012-01-23there's an attr_accessor, and that adds the children method. This is ok. \n \n-bt
92DEFER

In the chapters about Prolog, tuples and list are mentioned.

1. Prolog does not have a real tuple type, and especially not a constant access one.
2. It is not true that lists and tuples are “containers” respectively of variable and fixed size.

In Prolog there is a binary left associative term constructor ,/2 which is what is used to build things which look as tuples:

?- (1, (2, (3, 4))) = (1, 2, 3, 4).
true.

?- (((1, 2), 3), 4) = (1, 2, 3, 4).
false.

In fact, what looks like a tuple is simply a nested term, not different from lists. Things are slightly more complicated as there is a ,/2 predicate which represents the logical conjunction of two predicates:

?- (true, false).
false.

?- (true, true).
true.

The list functor is ‘.’.

?- .(3, []) = [3].
true.

The usual […] syntax is just syntactic sugar.

Essentially a list is not a “mutable size container” (lists are essentially immutable[0]).
It is just a cons list, like in Scheme. Simply the pair constructor is . and not cons.

?- ‘,’(3, 4) = (3, 4).
true.

The ‘term’ syntax can be used essentially to bypass usual precedence rules which would make the desugared version ,(3, 4) a syntax error.

Since in Prolog it is possible to use any functor (including ‘,’) to build terms of arbitrary arity, it is correct to write:

?- X = ‘,’(3, 4, 5).
X = ‘,’(3, 4, 5).

However, that is not a tuple type:

?- ‘,’(3, 4, 5) = (3, 4, 5).
false.

Because (1, (2, (3, 4))) = (1, 2, 3, 4).


[0] In some sense it can be “modified” because if we have variables we can “extend” the list through unification if the last term is a variable
(this is also the basis for difference lists). Same applies to tuples, though.

?- (1, A) = (1, 2, 3).
A = (2, 3).

Ah... the danger of writing about a language that is relatively new to me. Unfortunately, this error is pervasive in the chapter, and pretty difficult to fix at this stage. I am going to have to wait until the next edition. \n \nThanks for the catch, and sorry for the error.
12TYPO

The output of the two puts is on the same line but should be on the next line

>> puts “hello, #{language}”hello, Ruby
=> nil
>> language = ‘my Ruby’
=> “my Ruby”
>> puts “hello, #{language}”hello, my Ruby

2012-01-21
224ERROR

In the middle of the page, there is a sentence saying: “count in this context is a higher-order function.”

I think map should be the high-order function in this context.

2012-01-21
140TYPO

val hobbits = Set(“frodo”, “samwise”, “pippin”)

should be
scala> val hobbits = Set(“frodo”, “samwise”, “pippin”)

in order to follow the convention that code executed at the command line is clearly distinguished from the rest of the text. Additionally, it should be syntax highlighted.

2012-01-21
148TYPO

“On the next page is an example of a regular expression that can match uppercase or lowercase F at the beginning of a string.”
In the PDF, the regular expression is on the same page, and it makes even less sense in a mobile format. Something like “Below is an example of a regular expression that can match uppercase or lowercase F at the beginning of a string.” would be page-independent.

2012-01-21
154TYPO

“Find.” should be “Find:”

2012-01-21
185ERROR

It’s receive … end not loop() … end

2012-01-21
183TYPO

There are n commas in the tuples of the shopping list in exercise 2.

Consider a shopping list that looks like [{item quantity price}, …]. Write a list comprehension that builds a list of items of the form [{item total_price}, …], where total_price is quantity times price.

should be

Consider a shopping list that looks like [{item, quantity, price}, …]. Write a list comprehension that builds a list of items of the form [{item, total_price}, …], where total_price is quantity times price.

2012-01-21
192TYPO

The code sample for error trapping on this page is inconsistent with the description and the code on the previous page.

{’EXIT’, From, Reason} ->
io:format(“The shooter died. Start another one.~n”),
loop()
end.

should be

{’EXIT’, From, Reason} -> io:format(“The shooter ~p died with reason ~p.”, [From, Reason]),
Download erlang/coroner.erl
io:format(“Start another one.~n”),
loop()
end.

2012-01-21
94ERROR

All the Prolog code that is downloaded from the site is incorrectly commented at the top. The comments should be preceded with % instead of #. When loading the code, it doesn’t compile with the comments.

2012-01-21
35DEFER

You say “… class will be much more difficult to debug because Ruby can no longer tell when a method is missing. We would definitely want strong error checking to make sure it was accepting valid Roman numerals.”

But, adding a line such as

return super if (!name.to_s.match(/[IVXLC]+$/))

first thing in the method_missing definition, Ruby will be able to handle the missing methods just fine.

The problem of finding the definition of the methods remains, of course.

I’d personally strip the quoted lines from that paragraph and add them as an introduction to an exercise to find the return super if cannot_handle_method idiom.

Your design is better than mine. Perhaps in the next edition?
239DEFER

In Hackers and Painters, Graham chronicles a start-up that leveraged produc- tivity with Lisp to achieve productivity that no other vendors could match.

should probably be:

In Hackers and Painters, Graham chronicles a start-up that leveraged Lisp to achieve productivity that no other vendors could match.

Good suggestion. Will consider for next edition.
253TYPO

“seen lists” has no space:

You’ve seenlists in many different languages.

2012-01-21
171DEFER

The Fibonacci sequence is defined with the 0th element as 0. The definition on page 171, as another_fib, starts with the 0th element as 1.

You're right, of course. I'm not going to change it here, as the intention is clear enough and I would be likely to inject more errors in the manuscript by fixing the problem. \n \nI am going to wait for the next edition to fix this one, ok? \n
250DEFER

The Fibonacci sequence is defined with the 0th element as 0. The definition on page 250, as fib, starts with the 0th element as 1. This gives different results from the alternative definition on page 251 where the 0th element is 0.

Good catch, but I think the intent is clear, and don't want to risk turning a small problem into a bigger one. Will consider for the next release. Thanks for finding this one. \n \n
228ERROR

You wrote "When Clojure parses code, it first breaks the program down into pieces called forms. Then, Clojure can compile or interpret the code’. However, Clojure code is always compiled to bytecode — even at the REPL. It’s not interpreted at all.

2012-01-21
79ERROR

Downloadable source file (friends.pl) given on this page produces compile error due to incorrect comment delimiter. (Am using GNU Prolog 1.3 per author’s suggestion.) Replacing all single-line comment delimiters with % (percent sign) fixes the problem.

2012-01-21Ah. These are auto-generated, and not by me. I will leave a note to the prags.
15OK

In the code examples at the bottom of the page:

The irb warning code for “string literal in condition” is 13 and not 31 as printed.

2012-01-23Good eye! \n \nThis is a line number and thus will be different, depending on how many lines you've typed into the console. \n \n-bt
26OK

Bug: In the implementation of the Tree class in ruby, running the given program gives the following error: tree.rb:11:in `visit_all’: undefined local variable or method `children’ for # (NameError)
\tfrom tree.rb:28

Solution: on line 11, “children.each …” should instead reference an instance variable “@children.each …”

2012-01-23There's an attr_accessor at the top. That should add the "children" getter method. Perhaps you didn't type that line? \n \n It runs ok for me. \n \n-bt
105TYPO

On fourth bullet (line 16) Tail2-2 must read Tail2-B, Tail2 must read Tail2-A

131ERROR

The book translates some Scala to Ruby as:

args.each {|arg| println(arg)}

println isn’t a Ruby function so it should be ‘puts’

150ERROR

In the description of the sort example it is said “that will yield a case-insensitive sort”.
This is not true as the comparison is only performed on the first character of each word

238TYPO

On line 4-5
(SomeType.arg) means fire the constructor for SimpleCompass, binding arg to the first parameter.

should be

(SomeType.arg) means fire the constructor for SomeType, binding arg to the first parameter.

263ERROR

There is a discrepancy between the two implementations of the Fibonacci sequence on pages 262-263 of the UK edition.

The 1st fib implementation prints out the nth Fibonacci number like a zero based array (write out the 1st 10 numbers starting with a 0). For example fib 10 returns 89, which is the 11th Fibonacci number. The ‘x’ in the fibTuple is the correct fibonacci number though.

ZjaIXtzlDBERROR

That’s a knowing aenwsr to a difficult question

2012-03-27
232ERROR

In “you’ll define a higher-order function with the fn function”, “higher-order” should be “anonymous”. Using “fn” always defines an anonymous function which may or may not be higher order. Higher-order function may also be defined using “defn”. In fact your example using fn is not higher-order.

167TYPO

In the first paragraph of the Scala subsection titled “Concurrency” (bottom of the page numbered 167 on the page in the PDF —- my reader thinks it’s page 163), you’ve a sentence “Often, the actor uses a pattern matcher to detect the message and perform the appropriate message.” I think the last word should be “action”. Also, “classify” might be more appropriate than “detect”, but that’s a minor preference.

Thanks for writing the book!

144ERROR

In section “Classes in Scala”: class Person(firstName: String, lastName: String) doesn’t result in a class with firstName and lastName attributes, as the text says. It merely results in a class whose constructor takes two arguments but doesn’t do anything with them.

To get attributes, “val” must be added in from of the two parameters. Otherwise readers will be confused that they cannot access the supposed attributes if they experiment with the example:

scala> class Person(firstName: String, lastName: String)
defined class Person

scala> val gump = new Person(“Forrest”, “Gump”)
gump: Person = Person@43900f17

scala> gump.firstName
:10: error: value firstName is not a member of Person
gump.firstName
^

with val though:

scala> class Person(val firstName: String, val lastName: String)
defined class Person

scala> val gump = new Person(“Forrest”, “Gump”)
gump: Person = Person@707cdc58

scala> gump.firstName
res1: String = Forrest

148SUGGEST

In scala/employee.scala: Using “override val” for the name attribute in Employee is not necessary. It’s easier to write it like this:

class Employee(name: String, val number: Int) extends Person(name) {
…
}

This results in the Employee constructor taking the names as an argument and passing it on to Person, where it will live as a field.

If you use override val, it results in an override of the public getter method, which is not necessary as Person already provides that.

The same thing for scala/nice.scala, this way is much better:

class Character(name: String) extends Person(name) with Nice

148SUGGEST

In scala/employee.scala: “id():String” isn’t recommended style, the colon should always be followed by a space. It’s right most of the time, but it’s not consistent (it looks unclean).

Other examples of missing space after colon is in scala/nice.scala, on page 151. Maybe other places, but I’m not yet as far :).

4345ERROR

The attr keyword defines an instance variable. Several versions exist. The most common are attr (defining an instance variable and a method of the same name to access it)…

Presumably this should be attr_reader rather than attr?

279ERROR

Instead of
“foldl1 (+) 0 [1 .. 3]”
it should either read
“foldl (+) 0 [1 .. 3]”
or
“foldl1 (+) [1 .. 3]”

Anyway, it might be a good idea to shortly discuss the difference between foldr/foldl and foldr1/foldl1 or leave out the latter version. IMO this difference is not related to the application of an operator, e.g. (+), in contrast to an anonymous function.

173ERROR

4 + “string”.
“Unlike Scala, there’s no coercion between strings and ints.”

Yes, but the example is misleading since + doesn’t concatenate strings, e.g.
“4” + “string”.
yields the same exception.

175ERROR

{comic_strip, {name, “Calvin and Hobbes”}, {character, “Spaceman Spiff”}}.
“We’ve represented a hash for a comic strip.”
…
“If you are used to Ruby or Java-style hashes, it may seem strange to have the initial atom …”

The code shows a way to represent key-value associations but I don’t think there’s any hashing going on here. The order of key-value pairs matters and a key may appear multiple times. Can it look up values by key?

The initial atom is a simple way to indicate type information (what Scala does with case classes) and indeed it doesn’t fit the hash table concept.

215ERROR

Section: Booleans and Expressions

(= 1 1.0) returns false in Clojure 1.3. Is that a language change? (== 1 1.0) does return true.

235ERROR

Section: Infinite Sequences and take

Perhaps it’s a language change in Clojure 1.3, but the fib-pair example as written gets an ArithmeticException integer overflow. Starting iterate with [1N 1N] gets it to happily use BigInt values.

BTW there’s no need to map first over all the iterated values — it’s enough to take the first of the nth pair — but maybe you wrote it that way to demonstrate that map works on infinite sequences.

Is it typical Clojure code to compute one more fibonacci number than needed vs. returning the second element of the previous fib-pair?

251TYPO

One of the titles used in “Working with Atoms” does not match. “Seven Languages” becomes “Seven Languages in Seven Weeks”.

user=> (swap! top-sellers conj {:title “Seven Languages”, :author “Tate”})
[{:title “Seven Languages in Seven Weeks”, :author “Tate”}]

44TYPO

In the Tree code example, visit_all method, it should say @children.each instead of children.each

32ERROR

You list the “logical operators” | and & as behaving more or less like || and && but without shortcutting.

This is incorrect. | and & are the bitwise operators and the only reason they can behave somewhat like || and && in some circumstances is due to the specific types you have been comparing and how they have these operators implemented.

It is misleading not to specifically refer to these as the bitwise operators.

43SUGGEST

You describe “methods that test” as those that end in a question mark. I think you can be clearer than that about this Ruby idiom.

Specifically, methods that are expected to return a boolean are expected to end in a question mark. You could probably combine the description to include both ideas - testing something and the expectation of a boolean return value.

23%SUGGEST

During Day 2 of Io the reader is suddenly told to “Think of doMessage as somewhat like Ruby’s eval”. eval however was never mentioned any where in the Ruby section an far as I could see. Which can cause readers to stumble a bit. The explanation of what eval is follows in the next sentence, but it’s a bit weird to suddenly learn eval first after you are told to think of something else as eval.

25TYPO

In the 3rd paragraph of the “I Won’t Be Your Programming Reference” section, “I will walk you through examples in each languages” should be “I will walk you through examples in each language”.

219ERROR

Clojure: Under the Booleans and Expressions section, you give an example of
(= 1 1.0)
and in the example, it evaluates to true. When I run the example on my machine, it evaluates to false.

35TYPO

In the check out code of Duck Typing when discussing the type system the example
>>a = [‘100’, 100.0] returns [“100”, 100.0] not [‘100’, 100.0]

258ERROR

This page says:

“[…] if/then/else statement”

and later:

“In Haskell, if is a function”

Both are wrong — ‘if/then/else’ is an expression with special syntactic support.

260ERROR

“[…] use the let function […]”

let is not a function.

“in Haskell, let binds a variable to a function”

‘function’ should be replaced by ‘value’, as is shown in the following example.

267ERROR

“Haskell includes first-class ranges and some syntactic sugar to support them”

Ranges are not first-class, they’re just sugar for calls to functions from the Enum typeclass.

277ERROR

“f . g x” is not shorthand for “f (g x)”.

Example: “sum . map (+1)” is a valid function. “sum (map (+1))” is a type error.

282ERROR

at the top of the page:

“the types that each statement returns”

Those are expressions, not statements. Also, expressions do not return types.

283ERROR

At the top of the page:

“Suit and Rank are type constructors”

Suit and Rank are not type constructors — they’re types.

282TYPO

“a string is an array of characters […] represent the array of characters, with an array […]”

s/array/list/

282TYPO

“That means that the type Boolean will have a single value, either True or False.”

I think I get what this is saying, but it’s confusing, and taken literally is wrong — the type Boolean has two values.

287ERROR

“You can also specify boilerplate implementations.”

That should be ‘default’, not ‘boilerplate’.

289ERROR

“Haskell allows us to chain let expressions together and express the final form in an in statement.”

The example doesn’t show chained let expressions — it shows a single let expression.

There is no such thing as an ‘in statement’. That is part of the syntax of let expressions.

289SUGGEST

“Monads let you simulate program state.”

Many monads have nothing to do with state. This seems to imply that monads are only/best for stateful patterns.

“do syntax allows programs in the imperative style.”

‘Do syntax’ also allows non-imperative programs when working with other monads. Also, such programs can always be written without ‘do syntax’.

A monad has “a type constructor that’s based on some type of container.”
(p. 290) “type that can hold a value”

Many people (myself included) find this intuitive explanation actually makes it harder to grok monads. The problem is that some monads act like containers, and some don’t.

291SUGGEST

As mentioned in the 2nd monad law, “m >>= return = m”. However, both the treasureMap example on p. 291 and the last example on p. 294 make the mistake of using “m >>= return” instead of simply “m”.

If return needs to be demonstrated, it should be a useful example.

290ERROR

“return wraps up a function into a monad”

‘return :: Monad m => a -> m a’. It injects any value, not just functions, into the monad.

“>>= unwraps a function”

Same thing.

294ERROR

Just is not a type. It is a function of type ‘:: a -> Maybe a’.

The examples at the top of the page are confusing. They should probably be:

Prelude> Just “some string” :: Maybe String
…
Prelude> Nothing :: Maybe String
…

This shows that there can either be a value or not. However, “Just Nothing” is of a totally different type than ‘Just “some string”’.

“The bind is also easy. For Nothing, it returns a function returning Nothing. For Just x, it returns a function returning x.”

The Maybe implementation of >>= does not return a function.

296ERROR

“The fully polymorphic template system”

The type system is not a template system. Although there is something separate and unrelated called Template Haskell.

296ERROR

Haskell’s type system is referred to as ‘strong’ on this page and again on p. 298. It should be ‘static’/’statically’.

152TYPO

(Note that the page# is a guess based on other submissions since I’m reading the Kindle version.)

Under “What We Learned in Day 2”, in the fourth paragraph, the second sentence reads:

“We also used count, isEmpty, and first methods for obvious purposes.”

I looked manually and searched via the search function, but could find no example of a method named “first” being used.

276ERROR

Two issues [page 276-277]
The composition operator [pg276] is misused; “foo(bar x)” would be “(foo . bar) x”. “(foo x).(bar x)” can be written “(foo <*> bar) x” using applicatives, but that goes beyond the scope of the section.

Second, the starter ‘monad’ example [pg277] is also applicitive functor-ish rather than monad-ish. ‘>>==’ and ‘rtn’ are typed ‘Position a -> Position a’; to be monadic they must be type ‘a -> Position a’

Evaluation in a ‘do’ block is enforced by composition, but it is not the same as stringing functions together with the compose operator; if “(bar . foo) x” is valid for a monadic x, then the equivalent bind would be “return x >>= foo . return >>= bar . return”.

124TYPO

for loop example run as forLoop.scala, but called for_loop.scala on bottom of previous page

69ERROR

The first paragraph says “Create a list like this” then shows the method ‘list’.

Then there’s a paragraph explaining that there’s a shortcut method ‘list’, which we’ve already seen.

The first code example should probably use ‘toDos := List clone’ then append values.

72TYPO

In “What We Learned in Day 3” for Io (Chapter 3), it states “Next, we built an XML generator that used /method_missing/ to print XML elements.” however it was Io’s /forward/ that was used, and while a previous heading was called “Io’s missing_method” (p.67) and went on to say “You can use the /forward/ message in the same way that you would use Ruby’s /missing_missing/” (p.68) it seems a mistake to still refer to the Ruby construct in the Io summary.

83SUGGEST

In the Prolog code for map.pl on page 83, since the three colours are defined as being different through symmetric relations, there seems to be an unneeded line of code in the rule for coloring:

different(Alabama, Mississippini),

It’s the only instance of a symmetrically relational subgoal in the rule, all others having been omitted.

83SUGGEST

The definition of the friend rule works for very simple queries, but gives unexpected results when querying with an unbound variable (e.g. asking “who is the friend of wallace?”:

?- [user].

|: likes(wallace,cheese).
|: likes(grommit,cheese).
|: likes(wendolene,sheep).
|: friend(X,Y):- \\+(X = Y),likes(X,Z),likes(Y,Z).
|: % user://1 compiled 0.01 sec, 1,720 bytes
true.

?- friend(wallace,grommit).
true.

?- friend(wallace,X).
false.

This is because the “\\+(X = Y)” clause comes before the X and Y variables are bound to possible values by the “likes” statements. If the order of the clauses is changed, the query works:

?- [user].

|: likes(wallace,cheese).
|: likes(grommit,cheese).
|: likes(wendolene,sheep).
|: friend(X,Y):- likes(X,Z),likes(Y,Z),\\+(X = Y).
|: % user://2 compiled 0.01 sec, 480 bytes
true.

?- friend(wallace,grommit).
true.

?- friend(wallace,X).
X = grommit ;
false.

These examples use SWI Prolog, but I received the same results with GNU Prolog.

97TYPO

Stupid error I know, but it’s “Gromit” not “Grommit” - only one ‘m’ :)

249ERROR

Generating the 500th Fibonacci number using the following code:

(nth (map first (iterate fib-pair [1 1])) 500)

will not work, since the integer values will overflow. You get an error like this:

ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1388)

In order to successfully generate the number, the BigInt type must be explicit with [1N 1N] as the initial values:

user=> (nth (map first (iterate fib-pair [1N 1N])) 500)
225591516161936330872512695036072072046011324913758190588638866418474627738686883405015987052796968498626N

This is using Clojure 1.5.1 on Java 1.6

250SUGGEST

“We grab n elements from the infinite sequence (iterate inc 1). Then we take n of them and multiply them together with apply *.”

There seems to be a redundancy between these two sentences - we “grab n elements” and THEN “take n of them”? The inner function is not grabbing n of anything, it is starting generation of infinite elements lazily, and the only time we start limiting this is at “take n”.

252SUGGEST

You have written:
—-
You can verify that entering (String. “new string”) into the repl returns the new string “new string”.
—-

Entering that text into the repl does absolutely nothing to verify that it actually returns a new string, as it just returns the string in question.

Perhaps you could add some more code to make it a bit more clear, for example:

user=> (identical? “new string” “new string”)
true
user=> (identical? (String. “new string”) “new string”)
false

261ERROR

foldl1 only takes a function and a list. The example in the middle of the page provides 0 as an initial value to foldl1. Removing the zero makes the example work.

158TYPO

Inconsistent formatting and syntax highlighting
Code example not prefaced with “scala >” prompt

val hobbits = Set(“frodo”, “samwise”, “pippin”)
should be
scala> val hobbits = Set(“frodo”, “samwise”, “pippin”)

159SUGGEST

In getPageSizeConcurrently() ‘actor’ is used but not explained. I guessed that it’s a factory method in Actor (since that’s a new import not found in the ‘kids’ example on p.157) that creates an instance of Actor with the code block argument as the act() method and calling start on it…

279TYPO

Wrong order of arguments in ‘foldl (\\x carryOver -> carryOver + x) 0 [1 .. 10]’

The order and the following explanation would be correct for foldr but has to be reversed for foldl.

(Of course, it does not really matter for this particular function. Replace ‘x’ with ‘2 * x’ to see the difference).

227SUGGEST

The definition of left and right function on SimpleCompass can be improved by omitting the redundant SimpleCompass creation. At least as of Clojure 1.6.0 (which I am using), the functions could be simply “(left [_] (turn bearing 3))”

146ERROR

def turnRight() {
bearing = (bearing + 1) % directions.size
inform(“right”)
}

Should be:
def turnRight() {
bearing = (bearing + (directions.size + 1)) % directions.size
inform(“right”)
}

7779TYPO

When you call `postOffice messageTarget` it should report back the `postOffice` object memory address: `Object_0x100444b38`. It currently reports `Object_0x1004ce658`, which is incorrect.

104SUGGEST

In the explanation of the concatenate example

concatenate([], List, List).
concatenate([Head|Tail1], List, [Head|Tail2]) :-
concatenate(Tail1, List, Tail2).

you talk about List1, List2 and List3 which refers to
concatenate(List1, List2, List3) mentioned earlier. This is for the poor beginner, who tries to understand the logic way of doing things for the first time, extremely confusing. Would be better to either have a consistent naming or a completely different one.

Otherwise: thank you for this very valuable book!

84TYPO

Typo with foreach->forEach; “we iterate through the phone numbers in the list with forEach” should be “we iterate through the phone numbers in the list with foreach”.

76SUGGEST

> “The coroutines differed from concurrency in languages like Ruby, C, and Java because threads could only change their own state, leading to a more predictable and understandable concurrency model and less of a need for blocking states that become bottlenecks.”

This sentence is confusing. Coroutines are compared to threads, which are “leading to a more predictable and understandable concurrency model …” (?), but a few sections back it was said that threads are harder to use and debug (true).

  • Is that quoted part related to coroutines?
  • Or it seems that “actors” should be used instead of “threads” there, which is also confirmed in the Actors section on p.74.
  • Is it possible to rephrase the sentence?

Thanks.

18ERROR

The book states, “As always, you can find the answers in the back of the book.”

This is not in fact the case.

285SUGGEST

No one knows what is being asked in the Lazy sequence problem. It specifies function composition where the functions to work with have int -> [int] types.

83SUGGEST

In the prolog example, map.pl, there is:
different(Mississippi, Alabama),
…
different(Alabama, Mississippi)
…

Isn’t that redundant?

24ERROR

The examples of functions with associated code blocks (e.g. “in_case_of_emergency”) shows the named block defined before the function. This will not work; the block needs to come afterward, e.g.

def foo
…code goes here…
yield
…more code…
end

foo do
…code that runs when we call yield
end

278SUGGEST

The code snippet under “Different Computational Strategies” introduces the `instance` keyword without explanation.

281TYPO

The “What We Learned in Day 3” section says “We started with types, by looking at the inferred types of existing functions, numbers, booleans, and characters.” - but, in fact, no functions were examined (on pages 268-269)

248ERROR

Whenever you declare a module named Main in Haskell, and write just the provided code, you will encounter the following error:
The IO action ‘main’ is not defined in module ‘Main’
You either need to rename the module, or declare the following IO function.
main :: IO ()
main = return ()
Main is a specific module where the compiler waits for this specific function.
I’m using GHC v. 8.4.3

11SUGGEST

The code examples in the Kindle book are illegibly formated wrapped around in bad ways. I had to return the Kindle book, sorry.

223ERROR

The book reports:

`user => (= 1 1.0)
true`

but my repl reports:

`user => (= 1 1.0)
false
`

4444TYPO

“You’ve briefly seen modules in the code on page 42.” should be “You’ve briefly seen modules in the code on page 41.”

197SUGGEST

What I noticed in several places but especially in the Erlang chapter I’m currently looking at, are places where the flow would profit from rearranging some texts. Examples:

- On page 197, the paragraph “Like all other languages in this book…”, from my perspective definitely belongs under the “Core Weaknesses” subtitle, and not above it.
- On page 176 in Erlang’s Day 2, the function io:format to print something is explained. Yet anybody who did the “Day 1 Self-Study” already required this information; so for readers doing the self-study, this is superfluous information at this point.

Anyway, 8 years after coming out, still a good book to get to know different programming languages and paradigms!
Would you change the selection of languages, if you rewrote it now?

Categories: