Type helpers instead of UFCS
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 15 09:14:38 PDT 2015
On Saturday, 12 September 2015 at 20:37:37 UTC, BBasile wrote:
> 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.
>
> ...
How is this different to just having a specific type for the
first argument?
void writeln(Args...)(string s, Args args)
{
static import std.stdio;
std.stdio.writeln(s, args);
}
More information about the Digitalmars-d
mailing list