Thread overview
Pseudo Members
Feb 26, 2012
Vadim Goryunov
Feb 26, 2012
Vadim Goryunov
Feb 27, 2012
Brad Anderson
February 26, 2012
In "The D programming language" chapter 5.9.1 Pseudo Members Andrei says that D rewrites a.fun(b,c,d) as fun(a,b,c,d) if fun is not a member of a's type.
In the following example this is working for arrays only (T[]), but not for user defined class A.
Are pseudo members going to be implemented for user defined types eventually? Or is it considered a "hack" for arrays only?

class A {
    @property int length() { return 0; }
}

@property bool empty(T)(T a) { return a.length == 0; }

unittest {
    int[] array;
    array.empty;

    auto obj = new A();
    obj.empty;   // Error: no property 'empty' for class 'Test.A'
}


February 26, 2012
Apologies, I've just found there is a bug id for this

http://d.puremagic.com/issues/show_bug.cgi?id=3382

February 27, 2012
On Sun, Feb 26, 2012 at 3:44 AM, Vadim Goryunov <vadim.goryunov@gmail.com>wrote:

> Apologies, I've just found there is a bug id for this
>
> http://d.puremagic.com/issues/**show_bug.cgi?id=3382<http://d.puremagic.com/issues/show_bug.cgi?id=3382>
>
>
Here's a list of the remaining issues marked as discrepancies between the compiler and the book:

http://d.puremagic.com/issues/buglist.cgi?quicksearch=%5Btdpl%5D

Referring to that list and also the TDPL errata < http://erdani.com/tdpl/errata/> can be helpful when you encounter something in TDPL that isn't working.

Regards,
Brad Anderson