Hi Damien,
As far as I know this describes the Robert Hirschfeld's Convenience Methods
pattern. I wrote a code generator package which generates this pattern
through an API like this:
CGStConvenienceMethods uniqueInstance
setCleanTarget;
parameterCount: 2;
targetSelector: #cgConvEx2;
addReturn;
targetClassCategory: 'ConvenienceMethodsEx';
targetClass: #ConvenienceMethodsEx;
generateMethods.
That expression generates a class named ConvenienceMethodsEx with 3 methods:
#cgConvEx2
#cgConvEx2with:
#cgConvEx3with:with:
where each method passes nil as default parameter to it's "subsequent"
version (same selector +1 parameter).
Cheers,
Hernán
2016-01-20 12:08 GMT-03:00 Damien Cassou <[email protected]>:
> Hi,
>
> I would like to study the impact of adding optional parameters to
> keyword methods in Pharo. The goal of optional parameters is to
> facilitate the implementation of methods where some parameters are
> optional. For example, Seaside has:
>
> WAComponent>>request: aRequestString label: aLabelString
> default: aDefaultString onAnswer: aBlock
>
> ...
>
> This method of 4 arguments has only 1 required argument (aRequestString)
> and 3 optional ones. In the current implementation, this results in 7
> additional methods that only delegate directly or indirectly to the one
> above:
>
> - request:
> - request:default:
> - request:default:onAnswer:
> - request:label:
> - request:label:default:
> - request:label:onAnswer:
> - request:onAnswer:
>
> Before starting to implement anything, I need to know if it makes sense.
> If you want to help me, please send me all the use cases you have by
> giving me:
>
> - the library name (and URL if not in Catalog), or "pharo" if it's in
> Pharo
> - the class where this happens
> - the range of selectors that make sense
>
> For the example above, this would be:
>
> - Seaside
> - WAComponent
> - request:*
>
>
> Thank you very much
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>
>