Why we should remove {} from Squeak

Allen Wirfs-Brock Allen_Wirfs-Brock at Instantiations.com
Wed Oct 3 16:13:20 UTC 2001


At 06:54 PM 10/3/2001 +1200, Richard A. O'Keefe wrote:
>Here's a favourite example of mine.  In my XML kit, I have a function
>that finds a place in a tree and splits it at that point.  Conceptually,
>it's quite simple:
>
>     split_before :: (Tree -> Bool) Tree -> (Tree, Tree)
>     split_after  :: (Tree -> Bool) Tree -> (Tree, Tree)
...
>In Smalltalk, I have a choice of
>
>(a) tree2 := tree1 splitBefore aBlock.
>(b) aPair := tree1 splitBefore aBlock.
>     tree1 := aPair first.
>     tree2 := aPair second.
>(c) anArray := tree1 splitBefore aBlock.
>     tree1 := anArray first.
>     tree2 := anArray second.

I'd define a class named SplitTree with an instantiation message:
          on: aTree at: aBlock
  and with instance messages:
         preSplit
         postSplit

then when I pasted on of these beast around as an argument to other methods 
I'd see code like
         aSplitTree postSplit
if I'm reading this code a year after I wrote it  will probably be much 
more meaningful to me then
         anArray at: 2

Allen





More information about the Squeak-dev mailing list