RE: [GD-General] Re: Simulating constrained genericity in C++
Brought to you by:
vexxed72
From: Jesse J. <jes...@mi...> - 2001-12-27 00:31:22
|
At 3:19 PM -0800 12/26/01, Brian Hook wrote: > >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). Exactly. > >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. Maybe, but think about how you'd write generic code in a language like Smalltalk or Ruby. You'd use untyped objects and rely on the methods being present, just like you would with templates. If this is OK for those languages why is it a problem for templates? Of course you could say that one of the advantages of C++ is that you can use the type system to catch errors and templates don't follow this model. But I don't see this as a problem, especially given that not everything in C++ is an object. >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. You're in good company with that argument. :-) I don't quite buy it myself. It's awfully nice to be able to create new types and have them behave like the primitive types (think point, vector, complex classes). It's even nicer if you can do this without incurring a big performance hit. > >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). In a language that is statically typed and OO from the ground up constrained genericity *is* good. But that's not what I was getting at. Eiffel is a very nice statically typed OO language. But I want something more than C++ in a nicer package. I don't know what that might be right now, but I suspect it would include support for dynamic types and reflection. -- Jesse |