New programming paradigm
XavierAP via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 7 02:19:10 PDT 2017
On Wednesday, 6 September 2017 at 23:20:41 UTC, EntangledQuanta
wrote:
> So, no body thinks this is a useful idea or is it that no one
> understands what I'm talking about?
I think it may be a good use, although I haven't invested so much
time looking into your particular application.
It looks like a normal, sane use of templates. This is what they
are primarily intended for. And yes, combining them with mixins
provide some great possibilities that are not available in many
other languages.
Have you seen how D recommends avoiding duplicate code when
overloading operators, also by means of mixins:
https://dlang.org/spec/operatoroverloading.html#binary
I thought you may come from C since you mention void pointers as
an alternative. But that is not considered the normal way in D,
your new way is far better, and more "normal".
It looks you may be mistaking what happens at "run-time", or it
may be a way of speaking. In D, templates called with different
types generate different code already at compile-time -- even if
in the source code you write, it all looks and works so
polymorphically. This is a similar approach as in C++ and it's
why D generics are called "templates"; as opposed for example to
C#, where generics are not compiled into static types and keep
existing at run-time. Andrei discusses both approaches in his
book, and why the first one was chosen for D.
More information about the Digitalmars-d-learn
mailing list