Why so few binary method selectors? Because they're bad!

Marcel Weiher marcel at system.de
Thu Mar 18 10:38:00 UTC 1999


> ((AllClients collect: [:client | client employees])
> 	select: [:employee | employee isHandicapped])
> 		inject: 0 into: [ :total :employee | total +  
employee income]
>
> The trouble is the parenthesis make it a bit annoying.  I'd rather  
type
> it in using a more "algebraic" fashion.  Something like

Something I proposed (and partially implemented) a while back makes  
this look like the following

 total := 0 fold + AllClients collect employees select isHandicapped  
collect income.

However, this is still confusing, which is the reason I haven't  
released it yet.  Rethinking the same problem with dot notation  
(+crazy ideas) it becomes

  total := AllClients.each.employees.each.[ isHandicapped ].income sum.
or
  total := AllClients.*.employees.*.[ isHandicapped ].income sum.

assuming #sum is implemented to do a folding operation on  
collections, virtual or not.

(Pedantic note:  I think this clearly demonstrates how  
naming/selecting the participants differs from the action to be  
executed).

Marcel





More information about the Squeak-dev mailing list