[Issue 17910] Can't have UFCS in aggregate types
https://issues.dlang.org/show_bug.cgi?id=17910 --- Comment #5 from Steven Schveighoffer--- (In reply to anonymous4 from comment #4) > (In reply to Steven Schveighoffer from comment #3) > > make your extension methods global > > This destroys encapsulation: what has no business at global scope shouldn't > be there. Using clear(b) does not destroy encapsulation. > > > D usually frowns upon having the > > same code mean different things in different contexts. > > This is not the case for UFCS. Correct, it is not because local functions do not supersede global ones for UFCS. void foo(int) {} void main() { void foo(int) {} 1.foo; // calls global foo } --
[Issue 17910] Can't have UFCS in aggregate types
https://issues.dlang.org/show_bug.cgi?id=17910 --- Comment #4 from anonymous4--- (In reply to Steven Schveighoffer from comment #3) > make your extension methods global This destroys encapsulation: what has no business at global scope shouldn't be there. > D usually frowns upon having the > same code mean different things in different contexts. This is not the case for UFCS. --
[Issue 17910] Can't have UFCS in aggregate types
https://issues.dlang.org/show_bug.cgi?id=17910 --- Comment #3 from Steven Schveighoffer--- You have a choice, make your extension methods global, or don't use UFCS to call them: clear(b); This is a perfectly reasonable tradeoff. D usually frowns upon having the same code mean different things in different contexts. UFCS already pushes that envelope, we don't need to push it more. --
[Issue 17910] Can't have UFCS in aggregate types
https://issues.dlang.org/show_bug.cgi?id=17910 --- Comment #2 from anonymous4--- This destroys encapsulation: what has no business at global scope shouldn't be there. --
[Issue 17910] Can't have UFCS in aggregate types
https://issues.dlang.org/show_bug.cgi?id=17910 Steven Schveighofferchanged: What|Removed |Added Status|NEW |RESOLVED CC||schvei...@yahoo.com Resolution|--- |WONTFIX --- Comment #1 from Steven Schveighoffer --- Only non-member functions can be UFCS. I don't think this is going to change. This really is solved with the proposed "Self important" imports. See here: http://forum.dlang.org/post/pibniqywmlgdhgyaj...@forum.dlang.org Which also dip 1005 was aimed to solve, but not sure that is moving forward. --