About Go, D module naming

Jonathan M Davis jmdavisProg at gmx.com
Sun Dec 23 12:55:15 PST 2012


On Sunday, December 23, 2012 21:36:34 Phil Lavoie wrote:
> Never mind my last question. Found that it stands for: uniform
> function call syntax. Now I am going to look into what that means
> and how it affects the "no accessibility but visibility" thingy.

It means that any free function can be called as if it were a member function 
of the type that it takes as its first argument. So, it's possible to do 
something like

auto result = range.find(subRange);

instead of

auto result = find(range, subRange);

For better or worse, you can even do things like

int i = 5.min(12);

As for accessibility, if I had

struct S
{
}

auto foo(S) {...}

and code which did

s.foo();

if I added a private function named foo to S

struct S
{
    private auto foo() {...}
}

then all of a sudden, the s.foo() call would be illegal, because in UFCS, the 
member function always wins when there's a conflict. However, if private were 
hidden (or at least didn't factor into overload sets), then s.foo() wouldn't 
break as long as it was outside of the module that S was in, because the foo 
function in S then wouldn't affect anything outside of that module, since it 
would be inaccessible to anything outside of that module.

- Jonathan M Davis


More information about the Digitalmars-d mailing list