2 ms·
What do you mean by “twice as many places”? And looking up definitions is a job for the language server.
by xigoi 4y ago
What do you mean by “twice as many places”? And looking up definitions is a job for the language server.
- tsimionescu 4y agoWithout UFCS, if I see obj.foo(), I know I can lookup the definition of foo() in the definition of obj's type, or in its supertypes. Even for foo(obj), there is often a canonical place where such functions are defined. With UFCS, I need to look in both of these places until I can find the right definition. And sure, the IDE/language server/other tooling can often help, but not always (e.g. if I'm browsing some code on Github). Either way, more ambiguity for no gains is typically not a good idea, even if the downsides are minor (again, I am very much in favor of UFCS where it's directly useful, such as C++ or D).
- xigoi 4y agoIn languages that have UFCS, there's no such thing as classes, so… you simply look for the procedure.
- tsimionescu 4y agoD certainly has classes, and a member function has access to private members, while a free-floating function does not. Nim indeed doesn't seem to have this distinction at all, and only seems to support encapsulation at the module level, not the class level (as far as I could tell from very brief searching - I have never programmed in it).