digitalmars.D - Pseudo Members
- "Vadim Goryunov" <vadim.goryunov gmail.com> Feb 26 2012
- "Vadim Goryunov" <vadim.goryunov gmail.com> Feb 26 2012
- Brad Anderson <eco gnuk.net> Feb 27 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'
}
Feb 26 2012
Apologies, I've just found there is a bug id for this http://d.puremagic.com/issues/show_bug.cgi?id=3382
Feb 26 2012
--90e6ba308f0cae598304b9fa617c Content-Type: text/plain; charset=ISO-8859-1 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>
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 --90e6ba308f0cae598304b9fa617c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sun, Feb 26, 2012 at 3:44 AM, Vadim Goryunov <span dir=3D"ltr"><<a hr= ef=3D"mailto:vadim.goryunov gmail.com">vadim.goryunov gmail.com</a>></sp= an> wrote:<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" = style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Apologies, I've just found there is a bug id for this<br> <br> <a href=3D"http://d.puremagic.com/issues/show_bug.cgi?id=3D3382" target=3D"= _blank">http://d.puremagic.com/issues/<u></u>show_bug.cgi?id=3D3382</a><br> <br> </blockquote></div><br><div>Here's a list of the remaining issues marke= d as=A0discrepancies=A0between the compiler and the book:</div><div><br></d= iv><div><a href=3D"http://d.puremagic.com/issues/buglist.cgi?quicksearch=3D= %5Btdpl%5D">http://d.puremagic.com/issues/buglist.cgi?quicksearch=3D%5Btdpl= %5D</a> </div><div><br></div><div>Referring to that list and also the TDPL errata &= lt;<a href=3D"http://erdani.com/tdpl/errata/">http://erdani.com/tdpl/errata= /</a>>=A0can be helpful when you encounter something in TDPL that isn= 9;t working.</div> <div><br></div><div>Regards,</div><div>Brad Anderson</div> --90e6ba308f0cae598304b9fa617c--
Feb 27 2012









"Vadim Goryunov" <vadim.goryunov gmail.com> 