Category:Smalltalk: Difference between revisions

Content added Content deleted
Line 480: Line 480:
(knowing that the "ifXX"-methods send <tt>"value"</tt> to the corresponding arg and return that)
(knowing that the "ifXX"-methods send <tt>"value"</tt> to the corresponding arg and return that)


In this style, all of Smalltalk's control structures, loops, enumeration, stream readers and event the exception handling constructs are built. And since every class is open for extension, you can easily add additional convenient control functions (which is one place, where dialects differ, so very often, one has to transport some of those when porting apps from one dialect to another).
In this style, all of Smalltalk's control structures, loops, enumeration, stream readers and event- or exception handling constructs are built. And since every class is open for extension, you can easily add additional convenient control functions (which is one place, where dialects differ, so very often, one has to transport some of those when porting apps from one dialect to another).


The following is only a tiny subset - there are virtually hundreds or thousands of uses of blocks for control structures in the system.
The following is only a tiny subset - there are virtually hundreds or thousands of uses of blocks for control structures in the system.
Line 492: Line 492:
[ loop code . condition expression ] whileTrue.
[ loop code . condition expression ] whileTrue.
[ loop code ] doWhile:[ condition ].
[ loop code ] doWhile:[ condition ].
[ loop code ] doUntil:[ condition ].


n timesRepeat:[ block to be looped over ] "n being an integer"
n timesRepeat:[ block to be looped over ] "n being an integer"