[squeak-dev] The Trunk: Help-Squeak-TerseGuide-mt.15.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Jul 4 07:34:14 UTC 2022


Marcel Taeumel uploaded a new version of Help-Squeak-TerseGuide to project The Trunk:
http://source.squeak.org/trunk/Help-Squeak-TerseGuide-mt.15.mcz

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

Name: Help-Squeak-TerseGuide-mt.15
Author: mt
Time: 4 July 2022, 9:34:13.224724 am
UUID: 301d2672-16ba-1244-a7b1-18fc8486d00c
Ancestors: Help-Squeak-TerseGuide-mt.14

TerseGuide: sync #block and #conditionalExpression topics with recent updates on squeak.org

=============== Diff against Help-Squeak-TerseGuide-mt.14 ===============

Item was changed:
  ----- Method: TerseGuideHelp class>>block (in category 'pages') -----
  block
  	"This method was automatically generated. Edit it using:"
  	"TerseGuideHelp edit: #block"
+ 	<generated>
+ 	^(HelpTopic
- 	^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 ^,
+ 	as they can not return to the sender context
+  - use #cull: (and #cull:cull:...) if you do not know the exact number of arguments
+  - blocks (along with polymorphism on booleans) are the basis of control structures
+ 	-> See Conditional 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 := [ 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.					"local variable in a block"
- x := [:e | | v | v := 1. e + v] value: 2.					"localvar in a block"
  fac := [ :n | n > 1 ifTrue:  [n * (fac value: n-1)] ifFalse: [1]].	"closure on block variable"
  fac value: 5.											"closure variable scoped to its block"
  
+ !!' readStream nextChunkText)
+ 			key: #block;
+ 			shouldStyle: true;
+ 			yourself!
- !!' readStream nextChunkText!

Item was added:
+ ----- Method: TerseGuideHelp class>>conditionalExpression (in category 'pages') -----
+ conditionalExpression
+ 	"This method was automatically generated. Edit it using:"
+ 	"TerseGuideHelp edit: #conditionalExpression"
+ 	<generated>
+ 	^(HelpTopic
+ 		title: 'Conditional Expression'
+ 		contents: 
+ '"Conditional Expressions:
+  - Conditional expressions, or control structures in general, use
+ 	blocks as deferred computations which can be evaluated
+ 	selectively
+ "
+ | 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.
+ 
+ !!' readStream nextChunkText)
+ 			key: #conditionalExpression;
+ 			shouldStyle: true;
+ 			yourself!

Item was removed:
- ----- Method: TerseGuideHelp class>>conditionalStatement (in category 'pages') -----
- conditionalStatement
- 	"This method was automatically generated. Edit it using:"
- 	"TerseGuideHelp edit: #conditionalStatement"
- 	^HelpTopic
- 		title: 'Conditional Statement'
- 		contents: 
- '| 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.
- 
- !!' readStream nextChunkText!

Item was changed:
  ----- Method: TerseGuideHelp class>>pages (in category 'accessing') -----
  pages
  
  	^ #( introduction transcript assignment constants boolean arithmetic
+ 		bitwise conversion block exceptionHandling methodCall conditionalExpression
- 		bitwise conversion block exceptionHandling methodCall conditionalStatement
  		iterationStatement character string symbol  array orderedCollection
  		sortedCollection bag set interval association dictionary internalStream
  		fileStream date time point rectangle pen dynamic metaclass debugging
  		misc )!



More information about the Squeak-dev mailing list