www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos, std.typecons: arrays of Rebindable

reply pc <peng2cheng2 yahoo.com> writes:
I had problems sorting an array of Rebindable!(..).   Please see attached file.
 

Am I completely missing the point or is this a bug? Also, a shown in the file,
a hack to make this work may depend on a bug? in std.algoritm's swap function.
But I am way over my head. Just trying to help.  
Dec 26 2009
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
pc wrote:
 I had problems sorting an array of Rebindable!(..).   Please see
 attached file.
 
 Am I completely missing the point or is this a bug? Also, a shown in
 the file, a hack to make this work may depend on a bug? in
 std.algoritm's swap function. But I am way over my head. Just trying
 to help.
Thanks for raising the issue. I think it's a bug in Phobos. Could I impose on you to post the bug to our bugzilla? http://d.puremagic.com/issues/ Don't forget the attachments. Thanks! Andrei
Dec 26 2009
prev sibling parent pc <peng2cheng2 yahoo.com> writes:
Done.

I am only up to chapter 6, but so far, IMHO, TDPL is a really great book.
Thanks for writing it.

I would like to see a chapter that introduces (to the extent not discussed in
the context of generic functions and class), the template related concepts that
are manifest in std.traits, std.typetuple, std.algortim, std.typecons,
std.conv. Perhaps a second book - Phobos and D Tempates or the like is really
what is needed. Even if you can't fit this in, a little more explanation on how
to pick up imputed types like T and U in T[U], would be helpful.

In any case, I was at a loss understanding the "const(U), U" in the following
(from Rebindable in std.typecons) based on the description of "is Expresions"
at 2.4.1.4.3.

  static if (!is(T X == const(U), U) && !is(T X == invariant(U), U))

Granted, this example did not come from the book, and I know that you cannot
possibly explain everything, but I have the feeling that this way of picking up
U, as well as T, is fundamental and should not be left out of the book.

Like I said, the book is great -- even in draft.

Thanks again,

pc
Dec 26 2009