Template Oriented Programming
Justin Whear via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 17 13:53:53 PDT 2015
On Thu, 17 Sep 2015 20:41:11 +0000, Adam wrote:
> Is this the basic idea?
>
> Use templates when you want more power? That is, TOP can do everything
> OOP can do but more? Or are these ultimately two orthogonal concepts?
I think you've got the right idea. Some unordered thoughts:
* OOP provides run-time dynamism while TOP is strictly compile-time.
This means that TOP can produce optimal code via inlining and no
indirections, but also means that it can't do plugin systems via dynamic
libraries. You may, of course, mix the two.
* static if allows features to be enabled inline based on the
capabilities of the input types
* Since D code can generate entirely new code in the compiler, TOP offers
some serious potential for cool magic. Use wisely, of course.
* TOP moves the information bar back a step--instead of runtime
reflection the compiler provides compile-time reflection, allowing
runtime reflection to become a userspace library.
More information about the Digitalmars-d-learn
mailing list