Uniform Function Call Syntax in D - GameDev.net

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Sun Jul 1 11:53:36 PDT 2012


On Sun, 01 Jul 2012 11:13:10 -0400
Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:

> http://www.reddit.com/r/programming/comments/vvpfy/uniform_function_call_syntax_in_d_gamedevnet/
> 
> Andrei

Good article.

One of the commenters brought up a point about confusion from possible
conflicts between UFCS funcs and member funcs. I was just about to
reply saying that's not an issue in D because it would be a conflict
error, but I did a little test first:

-----------------------
import std.stdio;

void bar(Foo f) {
    writeln("UFCS");
}

struct Foo {
    void bar() {
        writeln("Member");
    }
}

void main()
{
    Foo f;
    f.bar();
}
-----------------------

That successfully compiles and prints "Member". Same thing happens if
you move the UFCS func and Foo definition out into their own separate
modules. But I was expecting a conflict error at compile-time. Is this
a bug?



More information about the Digitalmars-d-announce mailing list