News for hackers. Stuff that matters.
Re:Implementing UFCS for C++ in Clang by edsac_xyzw on Monday August 03, 2020 @03:20PM (#24042126)
C++ could adopt the UFCS universal-function-call feature of D-language that allows any ordinary free function to be called as if they were methods, without any special kind of type annotation. One of major advantages of UFCS is that it enhances the discoverability of free functions in IDEs. An user could write 'Object' followed by dot '.' and the IDE could show all possible functions applicable to that type. In D-language, the UFCS also works for primitive types such as int, double and so on.

D-Language UFCS: http://ddili.org/ders/d.en/ufcs.html and https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...

Re:Implementing UFCS for C++ in Clang by WalterBright on Monday August 03, 2020 @06:16PM (#24044114)
It also reduces the motivation to make "kitchen sink" classes. The idea is that functions that don't need access to private class members should not be member functions.
Re:Implementing UFCS for C++ in Clang by gpderetta on Monday August 03, 2020 @04:16PM (#24042831)
It could, but it keep getting rejected in committee votes, much to the frustration of Bjarne.
Re:Implementing UFCS for C++ in Clang by mhh__ on Monday August 03, 2020 @04:54PM (#24043278)
It's a shame. UFCS is one of the single biggest features that could really shave off huge amounts of boilerplate. It can also allow you to provide fine grained type safety where you may not usually be able to (as opposed to passing this down the chain a la operator<<)
Re:Implementing UFCS for C++ in Clang by leni536 on Monday August 03, 2020 @06:11PM (#24044070)
> C++ could adopt the UFCS universal-function-call feature of D-language that allows any ordinary free function to be called as if they were methods, without any special kind of type annotation.

It really couldn't. It would be a breaking change.

Re:Implementing UFCS for C++ in Clang by gpderetta on Tuesday August 04, 2020 @06:42AM (#24048590)
what would it break? It litterally was proposed by an extension, with support from Stroustrup.

IIRC Stroustrup regrets using . for member function calls (as opposed to just some syntactic sugar for any function call)

Re:Implementing UFCS for C++ in Clang by leni536 on Tuesday August 04, 2020 @04:47PM (#24054330)
The way it was worded in the GP comment would change name lookup in existing well-formed programs, making them fail to compile, or compile differently.

I'm not familiar with Stroustrup's proposal, but I doubt that he proposed it without some opt-in annotation.