Type helpers instead of UFCS

BBasile via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 12 13:37:35 PDT 2015


UFCS is good but there are two huge problems:
- code completion in IDE. It'will never work.
- noobs, code is unreadable.

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
{
     void writeln()
     {
         import std.stdio;
         writeln(subject);
     }
}
---

this will allow IDE plugins to provide better completion.

for example if 'Peter' types

---
void foo()
{
     import myhelper;
     "foobarbaz".
}
---

after the dot, 'Peter' can get ".writeln".
Why ? because a clear grammatical construction will allow an IDE 
plugin to work on a type and provides additional helpers that 
would be hard to put in the list without any specific grammatical 
construction.

...


More information about the Digitalmars-d mailing list