Gabriel Sechan wrote:
> ----------------------------------------
>   
>> Date: Mon, 7 Jan 2008 02:27:33 -0800
>> From: [EMAIL PROTECTED]
>> To: [email protected]
>> Subject: Re: Introducing Cobra
>>
>> Gabriel Sechan wrote:
>>     
>>> Templates solve a subset of it.  There's basicly 4 types of polymorphism.  
>>> Templates solve one.  Inheretence another.  C++ doesn't support the other 
>>> two.  Thats by design.  I have my issues with template syntax and a few 
>>> features, but lets be fair to them.
>>>   
>>>       
>> Oh, it's all about how much you want to abuse your templates.
>>
>> I've got three main types of polymorphism in mind:
>>
>> 1) Parametric
>> 2) Subtyping
>> 3) Ad-hoc
>>     
>
> Its more formal than that.  I'm on vacation in new orleans, so I don't have 
> my reference library.  But if you real C++ templates: The complete Guide (I 
> think you'd love it, btw), it defines 4 types of polymorphism very 
> distinctly.  The 4 types are made up on 2 axes.  One is when the decision is 
> made (run time, compile time), the other is wether the common interface 
> between the types is defined by an object or by the code (they called this 
> static vs dynamic, and I think I'm doing them a disservice by describ ing it 
> without the book in front of me).
>   
I do have it, and I couldn't remember what you were referring to, but
you intrigued me enough that I looked it up. The axis are static vs.
runtime and bounded vs. unbounded. The latter axis is misleading though
because it is entirely possible to take an unbounded system and make it
bounded (it's really easy to add a compile time check to see if you are
child of a particular base class). Having the extra freedom of being
unbounded is great, but there really isn't an upside (except from an
compiler/runtime implementer's perspective) to a bounded runtime. I'd
also argue that technically stuff like COM shows that C++ leaves enough
of a door open to do runtime, unbounded polymorphism, but concede that
the language really doesn't give you much to work with beyond function
pointers and RTTI (and COM doesn't even use the latter) to make that
happen. The truly unholy Objective-C++ gives you the whole kit and
caboodle though!

I'd also argue Josuttis' divisions are useful for contrasting C++
templates with it's virtual functions, but don't serve as a terribly
great taxonomy for polymorphism.

--Chris

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to