"static" UFCS

deadalnix deadalnix at gmail.com
Thu Jun 14 05:33:23 PDT 2012


Le 14/06/2012 08:46, Jacob Carlborg a écrit :
> UFCS can be used to emulate adding new members/instance methods to a
> class or struct:
>
> class Foo
> {
> }
>
> void bar (Foo foo, int x) {}
>
> auto foo = new Foo;
> foo.bar(3);
>
> Is it possible, somehow, to emulate adding new _static_ methods to a
> class, something like this:
>
> void fooBar (/*something*/, int x) {}
>
> Making this possible:
>
> Foo.fooBar(4);
>

I already think that static method was a bad idea from the « everything 
have to be an object » time.

The need for static function is pretty weak when we have free function 
and that they can access private objects data as needed.

What would be the use case for such a feature ?


More information about the Digitalmars-d mailing list