📄 block.st
字号:
"
Class Block.
Note how whileTrue: and whileFalse: depend upon the parser
optimizing the loops into control flow, rather than message
passing. If this were not the case, whileTrue: would have to
be implemented using recursion, as follows:
whileTrue: aBlock
(self value) ifFalse: [^nil].
aBlock value.
^ self whileTrue: aBlock
"
Class Block
[
newProcess
^ <NewProcess self>
|
newProcessWith: argumentArray
^ <NewProcess self argumentArray>
|
fork
self newProcess resume.
^ nil
|
forkWith: argumentArray
(self newProcessWith: argumentArray) resume.
^ nil
|
whileTrue
^ [self value ] whileTrue: []
|
whileTrue: aBlock
^ [ self value ] whileTrue: [ aBlock value ]
|
whileFalse
^ [ self value ] whileFalse: []
|
whileFalse: aBlock
^ [ self value ] whileFalse: [ aBlock value ]
|
value
<BlockExecute 0>
|
value: a
<BlockExecute 1>
|
value: a value: b
<BlockExecute 2>
|
value: a value: b value: c
<BlockExecute 3>
|
value: a value: b value: c value: d
<BlockExecute 4>
|
value: a value: b value: c value: d value: e
<BlockExecute 5>
]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -