Pipe syntax and the current methods

Bert Freudenberg bert at freudenbergs.de
Mon Aug 27 22:30:29 UTC 2007


On Aug 27, 2007, at 13:38 , Michael Lucas-Smith wrote:

>
>> With pipes, this could be written as
>>
>>    highestNumberedChangeSet
>>        "ChangeSorter highestNumberedChangeSet"
>>        ^self allChangeSetNames
>>            select:[:aString | aString startsWithDigit]  ;;
>>            collect:[:aString | aString initialIntegerOrNil] ;;
>>            ifNotEmpty:[:list | list max]
>>
> With pipe objects using standard smalltalk syntax, this could be  
> written as:
>
> highestNumberedChangeSet
>     "ChangeSorter highestNumberedChangeSet"
>       ^self allChangeSetNames asPipe
>           selecting: [:aString | aString startsWithDigit];
>           collecting: [:aString | aString initialIntegerOrNil];
>           ifNotEmpty: [:list | list max]

With the generic pipe object from my change-set in the original  
thread this gets you both - no need to define new methods:

    highestNumberedChangeSet
        "ChangeSorter highestNumberedChangeSet"
        ^self allChangeSetNames asPipe
            select:[:aString | aString startsWithDigit];
            collect:[:aString | aString initialIntegerOrNil];
            ifNotEmpty:[:list | list max]

>> which, with pipes, could be rewritten as...
>>
>>  self systemNavigation
>>    allCallsOn: assoc ;;
>>    collect: [:each | each classSymbol] ;;
>>    asSet ;;
>>    do: [:clsName | (Smalltalk at: clsName) replaceSilently:  
>> oldName to: aName].
>>
> And again:
>
> (self systemNavigation allCallsOn: assoc) asPipe
>   collecting: [:each | each classSymbol];
>   selectingAsUniqueSet;
>   do: [:clsName | (Smalltalk at: clsName) replaceSilently: oldName  
> to: aName]

and again, too:

self systemNavigation asPipe
    allCallsOn: assoc;
    collect: [:each | each classSymbol];
    asSet;
    do: [:clsName | (Smalltalk at: clsName) replaceSilently: oldName  
to: aName].

- Bert -





More information about the Squeak-dev mailing list