Required Reading: "How Non-Member Functions Improve Encapsulation"

codephantom me at noyb.com
Wed Nov 1 03:38:32 UTC 2017


On Tuesday, 31 October 2017 at 15:45:42 UTC, H. S. Teoh wrote:
> The one case where the difference matters is when you're trying 
> to debug something.  In that case, I'd say the onus is really 
> upon the debugger to tell you what kind of function it was.

Yes, this is my main concern I guess, as I use pretty plain 
editors that tell me nothing. I rely on the code to tell me what 
I need to know.

foo.bar();
foo.\bar();  // where \ means a free function

A different syntax for calling free functions would certainly 
make it clearer (as the above demonstrates), but as you argue, it 
would have a negative effect on encapsulation.

I guess with a more enhanced editor I could just mouse over UFCS 
syntax, and it could identify a free function from a member 
function. That would be nice, since there's no other way to know 
without exploring code elsewhere...

I guess the days of use a plain text editor...are slowly coming 
to and end ;-(

..what a shame...as I only just recently 'upgraded' from using vi 
to using micro....

https://github.com/zyedidia/micro



More information about the Digitalmars-d mailing list