# [Pkg] The Trunk: Help-Squeak-TerseGuide-tpr.8.mcz

commits at source.squeak.org commits at source.squeak.org
Wed May 30 23:36:53 UTC 2018

```tim Rowledge uploaded a new version of Help-Squeak-TerseGuide to project The Trunk:
http://source.squeak.org/trunk/Help-Squeak-TerseGuide-tpr.8.mcz

==================== Summary ====================

Name: Help-Squeak-TerseGuide-tpr.8
Author: tpr
Time: 30 May 2018, 4:36:43.105355 pm
UUID: 9754754a-173e-4793-b0c0-1dc047ec9bf6
Ancestors: Help-Squeak-TerseGuide-topa.7

Update some help related methods; plenty more to come in this class.

=============== Diff against Help-Squeak-TerseGuide-topa.7 ===============

Item was changed:
----- Method: TerseGuideHelp class>>arithmetic (in category 'pages') -----
arithmetic
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #arithmetic"
-
^HelpTopic
title: 'Arithmetic Expressions'
contents:

'"************************************************************************
* Arithmetic expressions:															*
************************************************************************"
| x |
x := 6 + 3.								"addition"
x := 6 - 3.								"subtraction"
x := 6 * 3.								"multiplication"
x := 1 + 2 * 3.							"evaluation always left to right (1 + 2) * 3"
x := 5 / 3.								"division with fractional result"
x := 5.0 / 3.0.							"division with float result"
x := 5.0 // 3.0.							"integer divide"
x := 5.0 \\ 3.0.							"integer remainder"
x := -5.									"unary minus"
x := 5 sign.								"numeric sign (1, -1 or 0)"
x := 5 negated.							"negate receiver"
x := 1.2 integerPart.						"integer part of number (1.0)"
x := 1.2 fractionPart.					"fractional part of number (0.2)"
x := 5 reciprocal.						"reciprocal function"
x := 6 * 3.1.								"auto convert to float"
x := 5 squared.							"square function"
x := 25 sqrt.							"square root"
x := 5 raisedTo: 2.						"power function"
x := 5 raisedToInteger: 2.				"power function with integer"
x := 5 exp.								"exponential"
x := -5 abs.								"absolute value"
x := 3.99 rounded.						"round"
x := 3.99 truncated.						"truncate"
x := 3.99 roundTo: 1.					"round to specified decimal places"
x := 3.99 truncateTo: 1.					"truncate to specified decimal places"
x := 3.99 floor.							"truncate"
x := 3.99 ceiling.						"round up"
x := 5 factorial.							"factorial"
x := -5 quo: 3.							"integer divide rounded toward zero"
x := -5 rem: 3.							"integer remainder rounded toward zero"
x := 28 gcd: 12.							"greatest common denominator"
x := 28 lcm: 12.							"least common multiple"
x := 100 ln.								"natural logarithm"
x := 100 log.							"base 10 logarithm"
x := 100 log: 10	.						"logarithm with specified base"
x := 100 floorLog: 10.					"floor of the log"
x := 0.7 sin.								"sine"
x := 0.7 cos.							"cosine"
x := 0.7 tan.								"tangent"
x := 0.7 arcSin.							"arcsine"
x := 0.7 arcCos.							"arccosine"
x := 0.7 arcTan.							"arctangent"
x := 10 max: 20.							"get maximum of two numbers"
x := 10 min: 20.							"get minimum of two numbers"
x := Float pi.							"pi"
x := Float e.								"exp constant"
x := Float infinity.						"infinity"
x := Float nan.							"not-a-number"
x := Random new next; yourself. x next.	"random number stream (0.0 to 1.0)"
x := 100 atRandom.						"quick random number"

'!

Item was changed:
----- Method: TerseGuideHelp class>>array (in category 'pages') -----
array
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #array"
-
^HelpTopic
title: 'Array'
contents:

'"************************************************************************
* Array:         Fixed length collection												*
* ByteArray:     Array limited to byte elements (0-255)								*
* WordArray:     Array limited to word elements (0-2^32)							*
************************************************************************"
| b x y sum max |
x := #(4 3 2 1).									"constant array"
x := Array with: 5 with: 4 with: 3 with: 2.			"create array with up to 4 elements"
x := Array new: 4.								"allocate an array with specified size"
x												"set array elements"
at: 1 put: 5;
at: 2 put: 4;
at: 3 put: 3;
at: 4 put: 2.
b := x isEmpty.									"test if array is empty"
y := x size.										"array size"
y := x at: 4.										"get array element at index"
b := x includes: 3.								"test if element is in array"
y := x copyFrom: 2 to: 4.						"subarray"
y := x indexOf: 3 ifAbsent: .					"first position of element within array"
y := x occurrencesOf: 3.						"number of times object in collection"
x do: [:a | Transcript show: a printString; cr].		"iterate over the array"
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)].		"test if all elements meet condition"
y := x select: [:a | a > 2].							"return collection of elements that pass test"
y := x reject: [:a | a < 2].							"return collection of elements that fail test"
y := x collect: [:a | a + a].						"transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: [].				"return first element that passes test"
y := x findFirst: [:a | a < 3].						"find position of first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum.		"sum array elements"
sum := 0. 1 to: (x size) do: [:a | sum := sum + (x at: a)].	"sum array elements"
sum := x inject: 0 into: [:a :c | a + c].				"sum array elements"
max := x inject: 0 into: [:a :c | (a > c)				"find max element in array"
ifTrue: [a]
ifFalse: [c]].
y := x shuffled.									"randomly shuffle collection"
y := x asArray.									"convert to array"
y := x asByteArray.								"convert to byte array"
y := x asWordArray.								"convert to word array"
y := x asOrderedCollection.						"convert to ordered collection"
y := x asSortedCollection.						"convert to sorted collection"
y := x asBag.									"convert to bag collection"
y := x asSet.									"convert to set collection"

'!

Item was changed:
----- Method: TerseGuideHelp class>>assignment (in category 'pages') -----
assignment
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #assignment"
-
^HelpTopic
title: 'Assignment'
contents:

'"************************************************************************
* Assignment:																		*
************************************************************************"
| x y z |
x _ 4.									"assignment (Squeak) <-"
x := 5.									"assignment"
x := y := z := 6.							"compound assignment"
x := (y := 6) + 1.
x := Object new.						"bind to allocated instance of a class"
x := 123 class.							"discover the object class"
x := Integer superclass.					"discover the superclass of a class"
x := Object allInstances.				"get an array of all instances of a class"
x := Integer allSuperclasses.			"get all superclasses of a class"
x := 1.2 hash.							"hash value for object"
y := x copy.								"copy object"
y := x shallowCopy.						"copy object (not overridden)"
y := x deepCopy.						"copy object and instance vars"
y := x veryDeepCopy.					"complete tree copy using a dictionary"

'!

Item was changed:
----- Method: TerseGuideHelp class>>association (in category 'pages') -----
association
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #association"
-
^HelpTopic
title: 'Association'
contents:

'"************************************************************************
* Associations:																		*
************************************************************************"
| x y |
x := #myVar->''hello''.
y := x key.
y := x value.

'!

Item was changed:
----- Method: TerseGuideHelp class>>bag (in category 'pages') -----
bag
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #bag"
-
^HelpTopic
title: 'Bag'
contents:

'"************************************************************************
* Bag:        like OrderedCollection except elements are in no						*
*                particular order														*
************************************************************************"
| b x y sum max |
x := Bag with: 4 with: 3 with: 2 with: 1.			"create collection with up to 4 elements"
x := Bag new.									"allocate collection"
y := x addAll: #(7 8 9).							"add multiple elements to collection"
y := x removeAll: #(7 8 9).						"remove multiple elements from collection"
y := x remove: 4 ifAbsent: [].					"remove element from collection"
b := x isEmpty.									"test if empty"
y := x size.										"number of elements"
b := x includes: 3.								"test if element is in collection"
y := x occurrencesOf: 3.						"number of times object in collection"
x do: [:a | Transcript show: a printString; cr].		"iterate over the collection"
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)].		"test if all elements meet condition"
y := x select: [:a | a > 2].							"return collection of elements that pass test"
y := x reject: [:a | a < 2].							"return collection of elements that fail test"
y := x collect: [:a | a + a].						"transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: [].				"return first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum.		"sum elements"
sum := x inject: 0 into: [:a :c | a + c].				"sum elements"
max := x inject: 0 into: [:a :c | (a > c)				"find max element in collection"
ifTrue: [a]
ifFalse: [c]].
y := x asOrderedCollection.						"convert to ordered collection"
y := x asSortedCollection.						"convert to sorted collection"
y := x asBag.									"convert to bag collection"
y := x asSet.									"convert to set collection"

'!

Item was changed:
----- Method: TerseGuideHelp class>>bitwise (in category 'pages') -----
bitwise
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #bitwise"
-
^HelpTopic
title: 'Bitwise Manipulation'
contents:

'"************************************************************************
* Bitwise Manipulation:																*
************************************************************************"
| b x |
x := 16rFF bitAnd: 16r0F.			"and bits"
x := 16rF0 bitOr: 16r0F.				"or bits"
x := 16rFF bitXor: 16r0F.				"xor bits"
x := 16rFF bitInvert.					"invert bits"
x := 16r0F bitShift: 4.				"left shift"
x := 16rF0 bitShift: -4.				"right shift"
x := 16r80 bitAt: 8.					"bit at position (0|1)"
x := 16r80 highBit.					"position of highest bit set"

'!

Item was changed:
----- Method: TerseGuideHelp class>>block (in category 'pages') -----
block
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #block"
-
^HelpTopic
title: 'Blocks'
contents:

'"************************************************************************
* Blocks:																			*
*    - blocks are objects and may be assigned to a variable						*
*    - value is last expression evaluated unless explicit return						*
*    - blocks may be nested														*
*    - specification [ arguments | | localvars | expressions ]							*
*    - ^expression terminates block & method (exits all nested blocks)			*
*    - blocks intended for long term storage should not contain ^					*
************************************************************************"
| x y z fac |
x := [ y := 1. z := 2. ]. x value.						"simple block usage"
x := [ :argOne :argTwo |   argOne, '' and '' , argTwo.].	"set up block with argument passing"
Transcript show: (x value: ''First'' value: ''Second''); cr.	"use block with argument passing"
x := [:e | | v | v := 1. e + v] value: 2.					"localvar in a block"
fac := [ :n | n > 1 ifTrue:  [n * (fac value: n-1)] ifFalse: ].	"closure on block variable"
fac value: 5.											"closure variable scoped to its block"

'!

Item was changed:
----- Method: TerseGuideHelp class>>boolean (in category 'pages') -----
boolean
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #boolean"
-
^HelpTopic
title: 'Boolean'
contents:

'"************************************************************************
* Booleans:																		*
************************************************************************"
| b x y |
x := 1. y := 2.
b := (x = y).								"equals"
b := (x ~= y).							"not equals"
b := (x == y).							"identical"
b := (x ~~ y).							"not identical"
b := (x > y).								"greater than"
b := (x < y).								"less than"
b := (x >= y).							"greater than or equal"
b := (x <= y).							"less than or equal"
b := b not.								"boolean not"
b := (x < 5) & (y > 1).					"boolean and"
b := (x < 5) | (y > 1).					"boolean or"
b := (x < 5) and: [y > 1].					"boolean and (short-circuit)"
b := (x < 5) or: [y > 1].					"boolean or (short-circuit)"
b := (x < 5) eqv: (y > 1).					"test if both true or both false"
b := (x < 5) xor: (y > 1).					"test if one true and other false"
b := 5 between: 3 and: 12.				"between (inclusive)"
b := 123 isKindOf: Number.				"test if object is class or subclass of"
b := 123 isMemberOf: SmallInteger.		"test if object is type of class"
b := 123 respondsTo: #sqrt.			"test if object responds to message"
b := x isNil.								"test if object is nil"
b := x isZero.							"test if number is zero"
b := x positive.							"test if number is positive"
b := x strictlyPositive.					"test if number is greater than zero"
b := x negative.							"test if number is negative"
b := x even.								"test if number is even"
b := x odd.								"test if number is odd"
b := x isLiteral.							"test if literal constant"
b := x isInteger.							"test if object is integer"
b := x isFloat.							"test if object is float"
b := x isNumber.						"test if object is number"
b := \$A isUppercase.					"test if upper case character"
b := \$A isLowercase.					"test if lower case character"

'!

Item was changed:
----- Method: TerseGuideHelp class>>character (in category 'pages') -----
character
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #character"
-
^HelpTopic
title: 'Character'
contents:

'"************************************************************************
* Character:																		*
************************************************************************"
| x y b |
x := \$A.										"character assignment"
y := x isLowercase.							"test if lower case"
y := x isUppercase.							"test if upper case"
y := x isLetter.								"test if letter"
y := x isDigit.								"test if digit"
y := x isAlphaNumeric.						"test if alphanumeric"
y := x isSeparator.							"test if seperator char"
y := x isVowel.								"test if vowel"
y := x digitValue.							"convert to numeric digit value"
y := x asLowercase.						"convert to lower case"
y := x asUppercase.						"convert to upper case"
y := x asciiValue.							"convert to numeric ascii value"
y := x asString.								"convert to string"
b := \$A <= \$B.								"comparison"
y := \$A max: \$B.

'!

Item was changed:
----- Method: TerseGuideHelp class>>conditionalStatement (in category 'pages') -----
conditionalStatement
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #conditionalStatement"
-
^HelpTopic
title: 'Conditional Statement'
contents:

'"************************************************************************
* Conditional Statements:															*
************************************************************************"
| x switch result |
x := 11.
x > 10 ifTrue: [Transcript show: ''ifTrue''; cr].		"if then"
x > 10 ifFalse: [Transcript show: ''ifFalse''; cr].	"if else"
x > 10											"if then else"
ifTrue: [Transcript show: ''ifTrue''; cr]
ifFalse: [Transcript show: ''ifFalse''; cr].
x > 10											"if else then"
ifFalse: [Transcript show: ''ifFalse''; cr]
ifTrue: [Transcript show: ''ifTrue''; cr].
Transcript
show:
(x > 10
ifTrue: [''ifTrue'']
ifFalse: [''ifFalse'']);
cr.
Transcript										"nested if then else"
show:
(x > 10
ifTrue: [x > 5
ifTrue: [''A'']
ifFalse: [''B'']]
ifFalse: [''C'']);
cr.
switch := Dictionary new.						"switch functionality"
switch at: \$A put: [Transcript show: ''Case A''; cr].
switch at: \$B put: [Transcript show: ''Case B''; cr].
switch at: \$C put: [Transcript show: ''Case C''; cr].
result := (switch at: \$B) value.

'!

Item was changed:
----- Method: TerseGuideHelp class>>constants (in category 'pages') -----
constants
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #constants"
-
^HelpTopic
title: 'Constants'
contents:

'"************************************************************************
* Constants:																		*
************************************************************************"
| b x |
b := true.								"true constant"
b := false.								"false constant"
x := nil.									"nil object constant"
x := 1.									"integer constants"
x := 3.14.								"float constants"
x := 2e-2.								"fractional constants"
x := 16r0F.								"hex constant".
x := -1.									"negative constants"
x := ''Hello''.								"string constant"
x := ''I''''m here''.							"single quote escape"
x := \$A.									"character constant"
x := \$ .									"character constant (space)"
x := #aSymbol.							"symbol constants"
x := #(3 2 1).							"array constants"
x := #(''abc'' 2 \$a).						"mixing of types allowed"

'!

Item was changed:
----- Method: TerseGuideHelp class>>conversion (in category 'pages') -----
conversion
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #conversion"
-
^HelpTopic
title: 'Conversion'
contents:

'"************************************************************************
* Conversion:																		*
************************************************************************"
| x |
x := 3.99 asInteger.				"convert number to integer (truncates in Squeak)"
x := 3.99 asFraction.			"convert number to fraction"
x := 3 asFloat.					"convert number to float"
x := 65 asCharacter.			"convert integer to character"
x := \$A asciiValue.				"convert character to integer"
x := 3.99 printString.			"convert object to string via printOn:"
x := 3.99 storeString.			"convert object to string via storeOn:"
x := 15 radix: 16.				"convert to string in given base"
x := 15 printStringBase: 16.
x := 15 storeStringBase: 16.

'!

Item was changed:
----- Method: TerseGuideHelp class>>date (in category 'pages') -----
date
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #date"
-
^HelpTopic
title: 'Date'
contents:

'"************************************************************************
* Date:																				*
************************************************************************"
| x y b |
x := Date today.								"create date for today"
x := Date dateAndTimeNow.					"create date from current time/date"
x := Date readFromString: ''01/02/1999''.			"create date from formatted string"
x := Date newDay: 12 month: #July year: 1999.	"create date from parts"
x := Date fromDays: 36000.						"create date from elapsed days since 1/1/1901"
y := Date dayOfWeek: #Monday.				"day of week as int (1-7)"
y := Date indexOfMonth: #January.				"month of year as int (1-12)"
y := Date daysInMonth: 2 forYear: 1996.			"day of month as int (1-31)"
y := Date daysInYear: 1996.						"days in year (365|366)"
y := Date nameOfDay: 1.						"weekday name (#Monday,...)"
y := Date nameOfMonth: 1.						"month name (#January,...)"
y := Date leapYear: 1996.						"1 if leap year; 0 if not leap year"
y := x weekday.									"day of week (#Monday,...)"
y := x previous: #Monday.						"date for previous day of week"
y := x dayOfMonth.								"day of month (1-31)"
y := x day.										"day of year (1-366)"
y := x firstDayOfMonth.							"day of year for first day of month"
y := x monthName.								"month of year (#January,...)"
y := x monthIndex.								"month of year (1-12)"
y := x daysInMonth.								"days in month (1-31)"
y := x year.										"year (19xx)"
y := x daysInYear.								"days in year (365|366)"
y := x daysLeftInYear.							"days left in year (364|365)"
y := x asSeconds.								"seconds elapsed since 1/1/1901"
y := x subtractDays: 10.							"subtract days to date object"
y := x subtractDate: (Date today).				"subtract date (result in days)"
y := x printFormat: #(2 1 3 \$/ 1 1).				"print formatted date"
b := (x <= Date today).							"comparison"

'!

Item was changed:
----- Method: TerseGuideHelp class>>debugging (in category 'pages') -----
debugging
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #debugging"
-
^HelpTopic
title: 'Debugging'
contents:

'"************************************************************************
* debugging:																		*
************************************************************************"
| a b x |
x := Object new.
String browse.							"browse specified class"
x inspect.								"open object inspector window"
x confirm: ''Is this correct?''.
x halt.									"breakpoint to open debugger window"
x halt: ''Halt message''.
x notify: ''Notify text''.
x error: ''Error string''.					"open up error window with title"
x shouldNotImplement.					"flag message should not be implemented"
x subclassResponsibility.				"flag message as abstract"
x errorImproperStore.					"flag an improper store into indexable object"
x errorNonIntegerIndex.				"flag only integers should be used as index"
x errorSubscriptBounds: 13.			"flag subscript out of bounds"
x primitiveFailed.						"system primitive failed"

a := ''A1''. b := ''B2''. a become: b.			"switch two objects"
Transcript show: a, b; cr.

x doesNotUnderstand: (Message selector: #foo).	"flag message is not handled"

'!

Item was changed:
----- Method: TerseGuideHelp class>>dictionary (in category 'pages') -----
dictionary
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #dictionary"
-
^HelpTopic
title: 'Dictionary'
contents:

'"************************************************************************
* Dictionary:																		*
* IdentityDictionary:   uses identity test (== rather than =)							*
************************************************************************"
| b x y sum max |
x := Dictionary new.								"allocate collection"
x at: #e put: 3.									"set element at index"
b := x isEmpty.									"test if empty"
y := x size.										"number of elements"
y := x at: #a ifAbsent: [].							"retrieve element at index"
y := x keyAtValue: 3 ifAbsent: [].					"retrieve key for given value with error block"
y := x removeKey: #e ifAbsent: [].				"remove element from collection"
b := x includes: 3.								"test if element is in values collection"
b := x includesKey: #a.							"test if element is in keys collection"
y := x occurrencesOf: 3.						"number of times object in collection"
y := x keys.										"set of keys"
y := x values.									"bag of values"
x do: [:a | Transcript show: a printString; cr].		"iterate over the values collection"
x keysDo: [:a | Transcript show: a printString; cr].			"iterate over the keys collection"
x associationsDo: [:a | Transcript show: a printString; cr].	"iterate over the associations"
x keysAndValuesDo: [:aKey :aValue | Transcript				"iterate over keys and values"
show: aKey printString; space;
show: aValue printString; cr].
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)].		"test if all elements meet condition"
y := x select: [:a | a > 2].							"return collection of elements that pass test"
y := x reject: [:a | a < 2].							"return collection of elements that fail test"
y := x collect: [:a | a + a].						"transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: [].				"return first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum.		"sum elements"
sum := x inject: 0 into: [:a :c | a + c].				"sum elements"
max := x inject: 0 into: [:a :c | (a > c)				"find max element in collection"
ifTrue: [a]
ifFalse: [c]].
y := x asArray.									"convert to array"
y := x asOrderedCollection.						"convert to ordered collection"
y := x asSortedCollection.						"convert to sorted collection"
y := x asBag.									"convert to bag collection"
y := x asSet.									"convert to set collection"

Smalltalk at: #CMRGlobal put: ''CMR entry''.		"put global in Smalltalk Dictionary"
x := Smalltalk at: #CMRGlobal.					"read global from Smalltalk Dictionary"
Transcript show: (CMRGlobal printString).		"entries are directly accessible by name"
Smalltalk keys do: [ :k |							"print out all classes"
((Smalltalk at: k) isKindOf: Class)
ifFalse: [Transcript show: k printString; cr]].
Smalltalk at: #CMRDictionary put: (Dictionary new).	"set up user defined dictionary"
CMRDictionary at: #MyVar1 put: ''hello1''.			"put entry in dictionary"
CMRDictionary size.		"dictionary size"
CMRDictionary keys do: [ :k |					"print out keys in dictionary"
Transcript show: k printString; cr].
CMRDictionary values do: [ :k |					"print out values in dictionary"
Transcript show: k printString; cr].
CMRDictionary keysAndValuesDo: [:aKey :aValue |	"print out keys and values"
Transcript
show: aKey printString;
space;
show: aValue printString;
cr].
CMRDictionary associationsDo: [:aKeyValue |		"another iterator for printing key values"
Transcript show: aKeyValue printString; cr].
Smalltalk removeKey: #CMRGlobal ifAbsent: [].		"remove entry from Smalltalk dictionary"
Smalltalk removeKey: #CMRDictionary ifAbsent: [].	"remove user dictionary from Smalltalk dictionary"

'!

Item was changed:
----- Method: TerseGuideHelp class>>dynamic (in category 'pages') -----
dynamic
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #dynamic"
-
^HelpTopic
title: 'Dynamic Message Calling/Compiling'
contents:

'"************************************************************************
* Dynamic Message Calling/Compiling:												*
************************************************************************"
| receiver message result argument keyword1 keyword2 argument1 argument2 |
"unary message"
message := ''factorial'' asSymbol.
result := Compiler evaluate: ((receiver storeString), '' '', message).
result := (Message new setSelector: message arguments: #()) sentTo: receiver.

"binary message"
message := ''+'' asSymbol.
argument := 2.
result := receiver perform: message withArguments: (Array with: argument).
result := Compiler evaluate: ((receiver storeString), '' '', message, '' '', (argument storeString)).
result := (Message new setSelector: message arguments: (Array with: argument)) sentTo: receiver.

"keyword messages"
keyword1 := ''between:'' asSymbol.
keyword2 := ''and:'' asSymbol.
argument1 := 10.
argument2 := 20.
perform: (keyword1, keyword2) asSymbol
withArguments: (Array with: argument1 with: argument2).
result := Compiler evaluate:
((receiver storeString), '' '', keyword1, (argument1 storeString) , '' '', keyword2, (argument2 storeString)).
result := (Message
new
setSelector: (keyword1, keyword2) asSymbol
arguments: (Array with: argument1 with: argument2))

'!

Item was changed:
----- Method: TerseGuideHelp class>>exceptionHandling (in category 'pages') -----
exceptionHandling
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #exceptionHandling"
-
^HelpTopic
title: 'Exception Handling'
contents:

'"************************************************************************
* Exceptions:																		*
************************************************************************"
| x |
x := Object new.
x error: ''Throwing an error''.

NotFound signal.								"simply throwing a specific exception"
NotFound signal: ''Throwing with a message''.	"throwing an exception with a custom text"

x := [ 5 / 0 ]							"simple exception handler"
on: ZeroDivide do: [ 10 ].
x := [ 5 / 0 ]							"processing the exception in an exception handler"
on: Error do: [:e | Transcript showln: e printString ].
x := [ 5 / 0 ]							"different exception handlers for the same block"
on: ZeroDivide do: [ 10 ]
on: MessageNotUnderstood do: [ 20 ].
x := [ 5 / 0 ]							"one exception handler for two different exceptions"
on: ZeroDivide , ArithmeticError do: [ 10 ].

'!

Item was changed:
----- Method: TerseGuideHelp class>>fileStream (in category 'pages') -----
fileStream
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #fileStream"
-
^HelpTopic
title: 'File Stream'
contents:

'"************************************************************************
* FileStream:																		*
************************************************************************"
| b x ios |
ios := FileStream newFileNamed: ''ios.txt''.
ios nextPut: \$H; cr.
ios nextPutAll: ''Hello File''; cr.
''Hello File'' printOn: ios.
''Hello File'' storeOn: ios.
ios close.

ios := FileStream oldFileNamed: ''ios.txt''.
[(x := ios nextLine) notNil]
whileTrue: [Transcript show: x; cr].
ios position: 3.
x := ios position.
x := ios next.
x := ios peek.
b := ios atEnd.
ios close.

'!

Item was changed:
----- Method: TerseGuideHelp class>>internalStream (in category 'pages') -----
internalStream
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #internalStream"
-
^HelpTopic
title: 'Internal Stream'
contents:

'"************************************************************************
* Internal Stream:																	*
************************************************************************"
| b x ios |
[(x := ios nextLine) notNil]
whileTrue: [Transcript show: x; cr].
ios position: 3.
ios position.
x := ios next.
x := ios peek.
x := ios contents.
b := ios atEnd.

ios position: 0.
[(x := ios nextLine) notNil]
whileTrue: [Transcript show: x; cr].
ios position: 6.
ios position.
ios nextPutAll: ''Chris''.
x := ios next.
x := ios peek.
x := ios contents.
b := ios atEnd.

'!

Item was changed:
----- Method: TerseGuideHelp class>>interval (in category 'pages') -----
interval
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #interval"
-
^HelpTopic
title: 'Interval'
contents:

'"************************************************************************
* Interval:																			*
************************************************************************"
| b x y sum max |
x := Interval from: 5 to: 10.						"create interval object"
x := 5 to: 10.
x := Interval from: 5 to: 10 by: 2.				"create interval object with specified increment"
x := 5 to: 10 by: 2.
b := x isEmpty.									"test if empty"
y := x size.										"number of elements"
x includes: 9.									"test if element is in collection"
x do: [:k | Transcript show: k printString; cr].		"iterate over interval"
b := x allSatisfy: [:a | (a >= 1) & (a <= 4)].		"test if all elements meet condition"
y := x select: [:a | a > 7].							"return collection of elements that pass test"
y := x reject: [:a | a < 2].							"return collection of elements that fail test"
y := x collect: [:a | a + a].						"transform each element for new collection"
y := x detect: [:a | a > 3] ifNone: [].				"return first element that passes test"
y := x findFirst: [:a | a > 6].						"find position of first element that passes test"
sum := 0. x do: [:a | sum := sum + a]. sum.		"sum elements"
sum := 0. 1 to: (x size) do: [:a | sum := sum + (x at: a)].	"sum elements"
sum := x inject: 0 into: [:a :c | a + c].				"sum elements"
max := x inject: 0 into: [:a :c | (a > c)				"find max element in collection"
ifTrue: [a]
ifFalse: [c]].
y := x asArray.									"convert to array"
y := x asOrderedCollection.						"convert to ordered collection"
y := x asSortedCollection.						"convert to sorted collection"
y := x asBag.									"convert to bag collection"
y := x asSet.									"convert to set collection"

'!

Item was changed:
----- Method: TerseGuideHelp class>>introduction (in category 'pages') -----
introduction
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #introduction"
-
^HelpTopic
title: 'General'
contents:

'"************************************************************************
* Allowable characters:															*
*    - a-z																			*
*    - A-Z																			*
*    - 0-9																			*
*    - .+/\*~<>@%|&?																*
*    - blank, tab, cr, ff, lf																*
*																					*
* Variables:																		*
*    - variables must be declared before use										*
*    - shared vars must begin with uppercase										*
*    - local vars must begin with lowercase											*
*    - reserved names: nil, true, false, self, super, and Smalltalk						*
*																					*
* Variable scope:																	*
*    - Global: defined in Dictionary Smalltalk and accessible by all					*
*         objects in system															*
*    - Special: (reserved) Smalltalk, super, self, true, false, & nil						*
*    - Method Temporary: local to a method										*
*    - Block Temporary: local to a block												*
*    - Pool: variables in a Dictionary object											*
*    - Method Parameters: automatic local vars created as a result of 				*
*         message call with params													*
*    - Block Parameters: automatic local vars created as a result of					*
*         value: message call															*
*    - Class: shared with all instances of one class & its subclasses				*
*    - Class Instance: unique to each instance of a class							*
*    - Instance Variables: unique to each instance									*
************************************************************************"