'Elements of Programming' is an amazing book by Alexander Stepanov and Paul McJones ( M. Stepanov is the primary designer of the C++ STL ).
Here is a rather long but insightful comment about the book : "Ask a mechanical, structural, or electrical engineer how far they would get without a heavy reliance on a firm mathematical foundation, and they will tell you, ‘not far.’ Yet so-called software engineers often practice their art with little or no idea of the mathematical underpinnings of what they are doing. And then we wonder why software is notorious for being delivered late and full of bugs, while other engineers routinely deliver finished bridges, automobiles, electrical appliances, etc., on time and with only minor defects. This book sets out to redress this imbalance.[...]" —Martin Newell, Adobe Fellow The book carefully crafts foundations for designing efficient, mathematically sound and generic algorithms. Apart from the fact this book is an absolute must read, I think the D community could really benefit from integrating these concepts. A minimalistic website maintains the concepts defined so far and the C++ code http://www.elementsofprogramming.com/ As an exercise I started to port the books concepts to D and the mathematical constructs do really fit nicely within the language. * D's purity can bring some guaranties that C++ can't ( see the definition for FunctionalProcedure in http://www.elementsofprogramming.com/eop-concepts.pdf ) * D's structs being value semantic, default constructible simplifies a lot. * Concepts translation into D's templates is very readable and straightforward. Now on the downside, D being a C-style-system-language, we won't be able to prevent implicit lossy conversions or add value domain constrains as in the X10 language for instance. But nonetheless I think it's still a worthwhile goal to seek. It would give more confidence in the code, both on correctness and genericity sides. So without further ado, here is my humble first attempt https://github.com/gchatelet/phobos/blob/traits_concepts/std/traits2.d And the associated more readable DDoc http://bbteam.fr/traits2.html I would like to hear what you think. Note : It's called traits2 because of a lack of inspiration not because I intend it to replace std.traits. -- Guillaume
