djohnson (22) [Avatar] Offline
#1
Where you say "we end up with two empty strings
(one at each end of the text)", actually, it's only one empty string, from the end of the text.
jon.skeet (451) [Avatar] Offline
#2
Re: Minor errata p. 67
Yes indeed - well spotted. Not sure where that came from... will update the errata page tonight.

Thanks!
djohnson (22) [Avatar] Offline
#3
Re: Minor errata p. 67
You're welcome. Your book is great. By the way, I made a little change to the Snippy code. You know how, when you load a new .scs file, the output area still shows the build and output results from the last file? I found this was disconcerting, so I put the line "output.Inlines.Clear();" into the "Open" method, at the end of the "if" block of code. I also gave the button labeled "Go" a name (goButton), and added the line "goButton.Focus();" to the same block of code.
jon.skeet (451) [Avatar] Offline
#4
Re: Minor errata p. 67
Will have a look at incorporating those changes when I get a chance. I haven't done much snippet loading, hence it was never a problem. Good idea though!

And I'll update the errata *now* before I forget...
jon.skeet (451) [Avatar] Offline
#5
Re: Minor errata p. 67
Okay, the erratum is at http://csharpindepth.com/ViewNote.aspx?NoteID=135

It also notes the effects of using verbatim string literals with Snippy...
djohnson (22) [Avatar] Offline
#6
Re: Minor errata p. 67
I think there's a typo on page 124, in the line "To carry our example forward, this means that you can convert implicitly from int? to
long? and from int to long? as well as explicitly from long? to int." Maybe the end of the line should read "as well as explicitly from int? to long."
jon.skeet (451) [Avatar] Offline
#7
Re: Minor errata p. 67
Will check when I'm not meant to be opening presents. Happy Christmas!
djohnson (22) [Avatar] Offline
#8
Re: Minor errata p. 67
Merry Christmas. Your book definitely helps in that regard. Here's one more typo, on page 180, in the block of code at the top, I think "Holdings holdings" should be "Holdings stocks".

Continuing to catch little things, the erratum which you have already listed on page 213 also occurs at the bottom of page 212, in this sentence:

For instance, you could use
var args = Environment.CommandLine;
In that case args would then be of type string[].

Also, on page 227, what's in the book is fine, but you've included Listing 8.6 in the Chapter 8 Snippets, and of course it doesn't build in Snippy since it doesn't have the definition of the Person class.

Here's a typo, or maybe some missing words. On page 230, at the end of the second sentence, you refer to "parameter covariance".

There's a typo on page 141. The second sentence in section 5.3 says "refer back to section 2.3.2", and it should be section 2.2.2.

On page 238, I don't understand the words "source event" in this phrase "We don’t log the details of the source event". Did you mean "event source" or "source of the event"?
jon.skeet (451) [Avatar] Offline
#9
Re: Minor errata p. 67
Thanks for all of these! Sounds like you've been reading both quickly and extremely attentively.

P124: New erratum: http://csharpindepth.com/ViewNote.aspx?NoteID=136

P212/213: I've expanded the original erratum.

P227: On this one I think I'm okay. If you go to the "Options" menu in Snippy, you should be able to select "Chapter 8" as the environment - listing 8.6 then builds. At least, it does with my version - please try it and report back!

P141: New erratum: http://csharpindepth.com/ViewNote.aspx?NoteID=139

P230: "parameter covariance" is actually what I meant. Parameters are treated covariantly (i.e. you can have a delegate type declared with a string parameter, and an instance of that delegate type referring to a method which takes an object parameter). By contrast, return types are treated contravariantly (which I didn't mention in that introduction).

P238: New erratum: http://csharpindepth.com/ViewNote.aspx?NoteID=138
jon.skeet (451) [Avatar] Offline
#10
Re: Minor errata p. 67
Oops, I missed the first one.

New erratum: http://csharpindepth.com/ViewNote.aspx?NoteID=140
djohnson (22) [Avatar] Offline
#11
Re: Minor errata p. 67
You're welcome. It's really nice to have a book which explains things as you do.

Okay, I see now about the Options menu in Snippy. I was wondering what those chapter menu items were for. I think you have to build Chapter 8 first, in Debug mode, and then Snippy can locate the reference when you build Snippy. Similarly for Chapter 11. (I don't think this is explained anywhere, in your book or in the code download, though it's alluded to in the second paragraph of page 30 of your book.) Anyway, it works now.

About covariance and contravariance, here is a reference to a page in MSDN entitled "Covariance and Contravariance in Delegates (C# Programming Guide)":
http://msdn.microsoft.com/en-us/library/ms173174.aspx
In the MSDN article they use contravariance when talking about parameters and covariance when talking about return types. So in fact do you, elsewhere in your book, and in your errata correction for page 57. So that's why I thought this instance on page 230 was a typo.

If it really isn't a typo, please tell me why.
jon.skeet (451) [Avatar] Offline
#12
Re: Minor errata p. 67
You're absolutely right - I clearly wasn't thinking straight before. Yes, it's a typo - I'll add an erratum later.

For the Snippy bit, I really ought to supply chapters 8 and 11 pre-built, or at least explain it somewhere...
jon.skeet (451) [Avatar] Offline
#13
Re: Minor errata p. 67
djohnson (22) [Avatar] Offline
#14
Re: Minor errata p. 67
Great. I'm not finding much more, but here's a grammar typo. On page 282, in the third paragraph, there's a sentence which reads "There’s currently has a single customer: Colin."

Meanwhile, I'm enjoying Chapter 11.

Also, in Chapter 9, there are two pages where you have the "extra code available" symbol. There's one on page 235, and I found the extra code just fine, in the "HigherOrderFunctions" folder. But the "extra code available" symbol also occurs on page 234, and I'm wondering if that one is a mistake.
jon.skeet (451) [Avatar] Offline
#15
Re: Minor errata p. 67
Thanks once again smilie

P282: http://csharpindepth.com/ViewNote.aspx?NoteID=142

P234 extra code: Hmm. I tended to put the "extra code available" icon in speculatively, and didn't always get round to writing the extra code itself I'm afraid. I'll see what I can do tomorrow. Basically it's likely to just be more examples of what is and isn't possible. Given the rate you're getting through the book and the close attention you're paying, I suspect it won't be significant for you smilie However, if there's anything you think would be particularly handy to demonstrate, I'm very happy to do what I can.

Have fun with the rest of the book!
djohnson (22) [Avatar] Offline
#16
Re: Minor errata p. 67
About page 234, the paragraph in question does seem pretty clear, especially now that I've read more of the book and gotten more comfortable with the concepts. That's actually why I thought the "extra code available" might have been a mistake. Possibly the paragraph was less clear when I read it the first time, but I don't remember the experience well enough to have any useful suggestions.

I think the main confusion may have been trying to locate the code for page 235, which I actually did want to see, and then finding it, but not being sure I had found the right code because I couldn't also find the code for page 234.
djohnson (22) [Avatar] Offline
#17
Re: Minor errata p. 67
Meanwhile, I tried to run the downloaded code mentioned at the bottom of page 306. The problem seems to be that the method WriteTo in the file LogEntry.cs was mostly commented out. Here it is:

internal void WriteTo(TextWriter writer)
{
Timestamp.ToString("R");
//writer.Write(Timestamp.ToString("u", CultureInfo.InvariantCulture));
//writer.Write(" ");
//writer.Write(Type);
//writer.Write(" ");
//writer.WriteLine(Message);
}

So it seems that the code in LogFileGenerator.cs was generating 20 files of 1000000 lines each, but none of the lines were written.
jon.skeet (451) [Avatar] Offline
#18
Re: Minor errata p. 67
Ah, rats. I'm 99% sure that happened while I was trying to find out why it was so darned slow. It turns out that date/time formatting and parsing is really painful. I'd expect the whole thing to be totally IO bound, and it's not.

I'll reinstate the code, add that extra code for P234, and update.
jon.skeet (451) [Avatar] Offline
#19
Re: Minor errata p. 67
Both done now - and I've organised the using statements for the whole of the OtherChapters solution too.

http://csharpindepth.com/Downloads.aspx
djohnson (22) [Avatar] Offline
#20
Re: Minor errata p. 67
I'm sure this is not what you want to hear, but there's a typo in the new code, in ImplicitParameterTypes.cs. The last example, which was supposed to be invalid, is the same as the previous, valid one:

// Invalid: out (and ref) parameters can't be implicit
//outAction = (out int x) => { x = 10; };

I'm assuming you meant to omit the "int" in the second line.

Also, in the LogFileGenerator.cs file, maybe the "const int EntriesPerFile" really shouldn't be 1000000. Maybe that's left over from when you were testing. I changed it to 100, and it runs just fine.

Also, in Chapter 12, page 319, the discussion at the end of section 12.1.2 may give the impression that the code in CleanDatabaseSlowly.cs is as effective as the code in CleanDatabaseQuickly.cs (just slower), but the former doesn't reset the identity columns.
jon.skeet (451) [Avatar] Offline
#21
Re: Minor errata p. 67
Doh doh doh!

Yes, I meant to omit the "out int" bit. Fixed, building the kit now.

As for the EntriesPerFile - I did mean it to be big, partly because then it makes a very good demonstration for why streaming is important. If you've only got a relatively small amount of data, you can cope with doing operations which buffer. If you have many gigs of it, you *have* to stream the data. (Push LINQ is better at this than LINQ to Objects - it's precisely the kind of thing it was designed for.) I've lowered it to 100000 though, so it's at least least somewhat quicker.

Regarding the CleanDatabaseSlowly - that's a good point. Note added:
http://csharpindepth.com/ViewNote.aspx?NoteID=143
djohnson (22) [Avatar] Offline
#22
Re: Minor errata p. 67
Anyway, thanks again for a great book. Push LINQ is a framework you're developing, is that it? Is it hard to understand?
jon.skeet (451) [Avatar] Offline
#23
Re: Minor errata p. 67
Push LINQ is something that Marc Gravell and I developed.

The best documentation I have for it at the moment is a blog post from a while ago:

http://msmvps.com/blogs/jon_skeet/archive/2008/01/04/quot-push-quot-linq-revisited-next-attempt-at-an-explanation.aspx

It's in MiscUtil (http://pobox.com/~skeet/csharp/miscutil) although it may well end up separated out as part of a new project soon.
djohnson (22) [Avatar] Offline
#24
Re: Minor errata p. 67
Just writing to say, thanks again for your book. I went back to some code which I was having trouble writing, and everything was better. The code is written now. I think your book had a really good influence on me, like, it improved my naming conventions, and my use of encapsulation, and my use of generics. With this difficult code, these things made a big difference.
jon.skeet (451) [Avatar] Offline
#25
Re: Minor errata p. 67
Cool - thank you *so* much for saying so.

If you'd be happy to contribute an Amazon review, that would be much appreciated - but no pressure!

Similarly, if you've got any suggestions for how I could improve next time I write a book (assuming there *is* a next time...) I'd really welcome the feedback.

Jon