T
Tony
class Interface
{
public:
virtual void DoItNow()=0;
};
class A: public Interface
{
public:
void DoItNow(); // satisfies interface explicitly
};
class B
{
public:
void DoItNow(); // could satisfy interface implicitly
};
// Must wrap B to get a class to behave like Interface
//
class C: public Interface
{
B rep;
public:
void DoItNow(){ rep.DoItNow(); }
};
void some_func(Interface* obj)
{
obj->DoItNow();
}
void another_func()
{
A a; // IS explicitly an Interface
B b; // is NOT an explicit Interface
C c; // wraps a B to use it as an Interface
some_func(&a); // obviously OK
some_func(&b); // error! b is not derived from Interface
some_func(&c); // obviously OK
}
If the second call worked via implicit interfaces, the
wrapper class C could be eliminated. Am I describing
dynamic typing? Are Implicit Interfaces what template-
only "concepts" (proposed) are hinting at? I don't think
it's dynamic typing, becuase I'd want to know at compile
time whether an object satisfies an interface or not.
Templates consider type while interfaces consider behavior.
Do Implicit Interfaces add "the other half" of what's missing
to templates? Replace them?
Just thinking out loud above and below...
class Drawable
{
virtual void Draw()=0;
};
class Window
{
void Draw();
};
class Graphic
{
void Draw();
};
class BillyTheKid
{
void Draw();
};
Window, Graphic, BillyTheKid are all Drawables implicitly.
A Graphic is not a Window though because Window is not an
interface class (pure ABC). Sure, you'll get weird results if
you pass a BillyTheKid to a Canvas object, but is the concept
of Implicit Interfaces still something to be pursued?
Hmmm.... I'm talking about "aspects" kinda? Do we need all
these mechanisms: templates, template concepts, aspects,
dynamic typing, implicit interfaces... others? I guess I'm
wondering in a remote way if impicit interfaces solve or could
solve a lot of the problems the other ones do.
Well that's enough brainstorming for Xmas night (!).
Tony
{
public:
virtual void DoItNow()=0;
};
class A: public Interface
{
public:
void DoItNow(); // satisfies interface explicitly
};
class B
{
public:
void DoItNow(); // could satisfy interface implicitly
};
// Must wrap B to get a class to behave like Interface
//
class C: public Interface
{
B rep;
public:
void DoItNow(){ rep.DoItNow(); }
};
void some_func(Interface* obj)
{
obj->DoItNow();
}
void another_func()
{
A a; // IS explicitly an Interface
B b; // is NOT an explicit Interface
C c; // wraps a B to use it as an Interface
some_func(&a); // obviously OK
some_func(&b); // error! b is not derived from Interface
some_func(&c); // obviously OK
}
If the second call worked via implicit interfaces, the
wrapper class C could be eliminated. Am I describing
dynamic typing? Are Implicit Interfaces what template-
only "concepts" (proposed) are hinting at? I don't think
it's dynamic typing, becuase I'd want to know at compile
time whether an object satisfies an interface or not.
Templates consider type while interfaces consider behavior.
Do Implicit Interfaces add "the other half" of what's missing
to templates? Replace them?
Just thinking out loud above and below...
class Drawable
{
virtual void Draw()=0;
};
class Window
{
void Draw();
};
class Graphic
{
void Draw();
};
class BillyTheKid
{
void Draw();
};
Window, Graphic, BillyTheKid are all Drawables implicitly.
A Graphic is not a Window though because Window is not an
interface class (pure ABC). Sure, you'll get weird results if
you pass a BillyTheKid to a Canvas object, but is the concept
of Implicit Interfaces still something to be pursued?
Hmmm.... I'm talking about "aspects" kinda? Do we need all
these mechanisms: templates, template concepts, aspects,
dynamic typing, implicit interfaces... others? I guess I'm
wondering in a remote way if impicit interfaces solve or could
solve a lot of the problems the other ones do.
Well that's enough brainstorming for Xmas night (!).
Tony