Fact checking for my talk
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 15 07:40:14 PDT 2016
On Mon, 15 Aug 2016 06:43:11 +0000, ZombineDev wrote:
> Well, I guess it would hard for me to convince you if you don't know
> what Design by Introspection means.
Some years ago I was on #d on freenode and someone made a reference to
high-order functions. I hadn't encountered the term, so I asked about it.
The person answered that if I didn't know what it meant, I must not use
high-order functions.
In point of fact I was making moderate use of high-order functions at
that time, but I hadn't heard that term for it. There is a difference
between knowing how to do a thing and knowing a specific term for that
thing.
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.
The term was coined by Andrei, and he's had a couple talks about it, but
nothing around here in the past few months.
This pattern is handy for certain types of library code. It's not
something that I have much use for.
More information about the Digitalmars-d
mailing list