RE: [GD-General] Re: Simulating constrained genericity in C++
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2001-12-26 23:19:33
|
>This approach is fundamentally wrong: unlike Eiffel C++ doesn't use >classes to model attributes like being assignable or addable. 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). >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. 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. There are reasonable reasons for saying: Foo a, b; if ( a < b ) return true; is prettier than: Foo a, b; if ( a.compareToFoo( b ) < 0 ) return true; But at least when I need to know where I'm comparing Foos I can find it immediately with grep. But that's neither here nor there =) >Eiffel reminds me of Modula-2: a really nice implementation of >yesterdays paradigm. But it just doesn't offer enough over C++ to be >compelling (for me at least). I don't know if Eiffel's implementation of constrained genericity is yesterday's paradigm; it's just a different way of doing things. Eiffel still has significant other problems, but I think its support of constrained genericity looks pretty elegant (at least, on paper). For me, the incremental advantages over C/C++ are probably to be found in Obj-C and Java. The former provides fully dynamic typing/message passing; the latter provides garbage collection and a shit load of stock libraries and cross-platform compatibility. Brian |