small fixups to the tutorial
Mathias Laurin <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.gnu.general |
|---|---|
| Message-ID | <[email protected]> |
Hi list, Zecke told me that I should send my patches to the mailing list, so here I am. I am half through the online tutorial now and I would have a few more typos, formatting, stuttering, and whitespace fixes. I have grouped them in a single patch: `typos_and_whitespace.diff`. Also, the `Checking` class' `printOn:` message (section 6.6.2) prints the `'` marks. The changes in `improved_checking_printon.diff` use the `stream nextPutAll` already introduced in 6.4.5 for a better looking `printOn:`. Also, I think that it could be a good idea to remove the blank lines from the code examples, here is what I mean: --- a/doc/tutorial.texi +++ b/doc/tutorial.texi @@ -1467,19 +1467,15 @@ more sanity checks to the writing of checks. writeCheck: amount [ <category: 'spending'> | num | - "Sanity check that we have checks left in our checkbook" (checksleft < 1) ifTrue: [ ^self error: 'Out of checks' ]. - "Make sure we've never used this check number before" num := checknum. (history includesKey: num) ifTrue: [ ^self error: 'Duplicate check number' ]. - "Record the check number and amount" history at: num put: amount. - "Update our next checknumber, checks left, and balance" checknum := checknum + 1. checksleft := checksleft - 1. because it would allow users to copy and paste the examples directly in a live interactive session. If you agree, I can make another patch. Finally, I am not sure whether I should write to the Changelog or you do it... I have not done it. In any case, thank you for the very nice tutorial! Best regards, Mathias _______________________________________________ help-smalltalk mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-smalltalk
improved_checking_printon.diff
(application/octet-stream, 527 B)
diff --git a/doc/tutorial.texi b/doc/tutorial.texi
index 458f9767..d3c11f9a 100644
--- a/doc/tutorial.texi
+++ b/doc/tutorial.texi
@@ -1525,9 +1525,9 @@ simple print-out functions.
@example
printOn: stream [
super printOn: stream.
- ', checks left: ' printOn: stream.
+ stream nextPutAll: ', checks left: '.
checksleft printOn: stream.
- ', checks written: ' printOn: stream.
+ stream nextPutAll: ', checks written: '.
(history size) printOn: stream.
]
check: num [
typos_and_whitespace.diff
(application/octet-stream, 3.1 KB)
diff --git a/doc/tutorial.texi b/doc/tutorial.texi
index b4a6e525..458f9767 100644
--- a/doc/tutorial.texi
+++ b/doc/tutorial.texi
@@ -280,8 +280,8 @@ which then prints out:
@end example
These examples show how to manipulate an array. They also
-show the standard way in which messages are passed arguments
-ments. In most cases, if a message takes an argument, its
+show the standard way in which messages are passed arguments.
+In most cases, if a message takes an argument, its
name will end with `:'.@footnote{Alert readers will remember that the math
examples of the previous chapter deviated from this.}
@@ -1433,7 +1433,7 @@ class.
@example
Checking extend [
- | history |
+ | history |
@end example
This is the same syntax as the last time we defined a checking account,
@@ -1448,12 +1448,12 @@ With our new Checking instance variable, we are all set to start recording
our checking history. Our first change will be in the handling of the
@code{init} message:
@example
- init [
- <category: 'initialization'>
- checksleft := 0.
- history := Dictionary new.
- ^ super init
- ]
+ init [
+ <category: 'initialization'>
+ checksleft := 0.
+ history := Dictionary new.
+ ^ super init
+ ]
@end example
This provides us with a Dictionary, and hooks it to our new
@@ -1612,7 +1612,7 @@ iterate across all entries in a collection.@footnote{The
We built our own code blocks, and handed them off for use by system
objects. But there is nothing magic about invoking code
blocks; your own code will often need to do so. This chapter
-will shows some examples of loop construction in
+will show some examples of loop construction in
Smalltalk, and then demonstrate how you invoke code blocks
for yourself.
@@ -1663,8 +1663,8 @@ As with the integer loops, the Interval class can also
represent steps greater than 1. It is done much like it was
for our numeric loop above:
@example
- i := (Interval from: 5 to: 10 by: 2)
- i do: [:x| x printNl]
+ i := Interval from: 5 to: 10 by: 2
+ i do: [:x | x printNl]
@end example
@node Invoking code blocks
@@ -1674,9 +1674,8 @@ Let us revisit the checking example and add a method
for scanning only checks over a certain amount. This would
allow our user to find ``big'' checks, by passing in a value
below which we will not invoke their function. We will
-invoke their code block with the check number as an argument
-ment; they can use our existing check: message to get the
-amount.
+invoke their code block with the check number as an argument;
+they can use our existing @code{check:} message to get the amount.
@example
Checking extend [
@@ -1689,8 +1688,8 @@ amount.
]
@end example
-The structure of this loop is much like our printChecks message
-sage from chapter 6. However, in this case we consider each
+The structure of this loop is much like our @code{printChecks}
+message from chapter 6. However, in this case we consider each
entry, and only invoke the supplied block if the check's
value is greater than the specified amount. The line: