Type helpers instead of UFCS

BBasile via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 12 17:36:14 PDT 2015


On Saturday, 12 September 2015 at 22:44:41 UTC, Idan Arye wrote:
> On Saturday, 12 September 2015 at 20:37:37 UTC, BBasile wrote:
>> That's why I propose the new keywords 'helper' and 'subject' 
>> that will allow to extend the properties pre-defined for a 
>> type, as long as the helper is imported:
>>
>> ---
>> module myhelper;
>> helper for subject : string
>
> Do we really need a 3-keyword chain? What's wrong with a simple 
> `helper : string` or `helper(string)`?
>
>> {
>>     void writeln()
>>     {
>>         import std.stdio;
>>         writeln(subject);
>>     }
>> }
>> ---
>
> Why `subject` to refer to the string the function gets called 
> on? What's wrong with good old `this`, which is used for this 
> purpose everywhere else?

no 'helper' is enough:

http://www.israpresse.net/wp-content/uploads/2015/05/625088-34.jpg






More information about the Digitalmars-d mailing list