[Python-Dev] *Simpler* string substitutions
David Abrahams
David Abrahams" <david.abrahams@rcn.com
Sat, 22 Jun 2002 07:35:03 -0400
----- Original Message -----
From: "Alex Martelli" <aleax@aleax.it>
> > I was thinking of the use of template specialization to describe the
> > relationship of a type to a library, e.g. specialization of
> > std::iterator_traits<libA::some_class> by libB, which makes
> > libA::some_class available for use as an iterator with the standard
library
> > (assuming it has some appropriate interface).
>
> That requires proper design for extensibility in advance -- the standard
> library must have had the forethought to define, and use everywhere
> appropriate, std::iterator_traits, AND libA must expose classes that
> can be plugged into that "slot".
Very true.
> As I tried indicating, if you're willing to require design-in-advance for
> such issues, PEP 246 (together with Python's general mechanisms)
> already offer what you need.
Super! +1
> Yes, factories and such creational patterns ARE a better long-term
> answer, BUT there's no denying that Ruby's ability to patch things
> up with duct tape (while having its own costs, of course!-) can
> be a short-term lifesaver. "If God had WANTED us to get things
> right the first time he wouldn't have created duct tape", after all:-).
In Alaska, where my wife grew up, they call it "100-mile-an-hour tape" --
good for any use up to 100 mph.
[apparently not for ducts, though, even if they're sitting still :(]
> > > Only Haskell's typeclass, AFAIK, has (among widely used languages and
> > > objectmodels) a smooth way to allow noninvasive 3rd party post-facto
> > > adaptation (and another couple of small gems too), but I guess it has
an
> > > easier life because it's compile-time rather than runtime.
> >
> > IIUC the same kind of thing can be implemented in C++ templates, if you
> > know where to look. There's been a lot of discussion of how to build
> > variant types lately.
>
> I don't think you can do it without some degree of design forethought,
> but admittedly I'm starting to get very slightly rusty (haven't designed
a
> dazzling new C++ template in almost six months, after all:-).
Well, I have to admit that I don't have the time to say anything backed up
by any research at this point ...I'm currently stuck in a Microsoft gravity
well trying to survive the descent... but thanks as always for your
educational and broad perspective!
-Dave