RE: [GD-General] Re: Simulating constrained genericity in C++
Brought to you by:
vexxed72
From: Patrick M D. <pa...@wa...> - 2001-12-27 07:24:50
|
On Wed, 26 Dec 2001, Brian Hook wrote: > So what does C++ use? Anything at all? Near as I can tell, from my > ages old usage of templates, C++ is like a static version of Obj-C -- if > the function call/operator overload doesn't exist that you need, you get > a compile time warning (in Obj-C you can still send a message that isn't > understood, which is unbelievably powerful). What happens to these messages that are not understood? Are these messages simply ignored? Does the recipient simply pass them on to another more knowledgeable target? Or can the recipient decode the types and content of the message? BTW, I'm curious to see something unbelievably powerful! :) > >of this templates work more like objects in a dynamic language and > >rely on name commonality. > > Right. And I'm not sure if relying on name commonality is really a good > design decision. When a language relies on inheritence for subtyping relationsips, then additional effort is required when an interface is created after a particular implementation is coded. One possible solution to this problem is to make a subclass of the implementation and specify the new interface that it satisfies. Unfortunately, this technique may not work when the object is created by a factory. So, using names (and their associated types) as a criteria for subtyping can be a more flexible approach that enables more code reuse. > For example, some STL classes require operator < to be overloaded, > which goes back to a thread on another mailing list where I said that > function name overloading is a Bad Idea so long as you're using text > as your representation because you can't find, for example, every > place you're doing a comparison between two specific types. Don't virtual methods suffer from the same problem. or do you consider that another form of function name overloading? Patrick |