Some Fundamental Paradigm Questions

Ron Tarrant rontarrant at gmail.com
Fri Dec 21 12:39:48 UTC 2018


Reading through an abstract of what makes the D language tick, I 
found terms like mixins and templates, concepts I haven't run 
across in the other languages I've learned.

I have a basic understanding of WHAT mixins and templates are, 
but what I don't understand is WHY they're part of the language, 
and thus my questions:

1) What problem does mixins solve?

2) Under what circumstances would I use mixins?

3) What problem does a template solve?

4) When would I use a template?


Learning PHP was my first exposure to OOP and it strikes me that 
OOP is the greatest thing since sliced bread (within reason, of 
course) and that leads me to wonder:

5) Are either mixins, templates, or both intended to make OOP 
code easier to read, more reliable, or in some other way improve 
the OOP coding experience?

6) Or, are mixins and templates completely different paradigms 
intended to solve problems in ways OOP can't?

So far in my searches, I've only found a tiny handful of GoF 
pattern examples in D, and so:

7) Is there a comprehensive stash/repository of GoF patterns 
implemented in D?

I'm mostly interested in factory, builder, mediator, and command 
patterns. I did find a very good thread-safe singleton example 
already (thank you David Simcha).


More information about the Digitalmars-d-learn mailing list