Fact checking for my talk

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 16 03:24:38 PDT 2016


On Monday, 15 August 2016 at 14:40:14 UTC, Chris Wright wrote:
> You still haven't defined the term "design by introspection". 
> Some searching around says it's the pattern of:
>
> template Foo(T) {
>   static if (is(typeof(T.bar)) {
>     // preferred implementation takes advantage of T.bar
>   } else {
>     // alternate (also correct) implementation
>   }
> }
>
> For instance, if T is an allocator and it has a `realloc` 
> method, the preferred implementation, which uses `realloc`, 
> will be chosen. Otherwise, the alternate implementation (which 
> might use a linked list to avoid reallocating) will be chosen.

Strategy pattern at compile time.


More information about the Digitalmars-d mailing list