[EMAIL PROTECTED] wrote on 10/05/2006 17:39:57: > At 11:21 AM 5/10/2006 +0100, [EMAIL PROTECTED] wrote: > >Have you taken a look at ConceptGCC? ( > >http://www.osl.iu.edu/~dgregor/ConceptGCC/) > > > >It's basically a first cut at implementing the Concepts which will be > >availiable in the next version of C++. They basically provide full compile > >time "duck typing" as well as adaptation for types that don't exactly fit > >the concept. (e.g if the type doesn't have a length method, here's how you > >provide it. > > > >It's a very powerfull idea, and probably well worth looking at for > >inspiration. > > FWIW, I skimmed through the tutorial; it appears that a "Concept" is > roughly equivalent to a typeclass in Haskell, and a "Model" is roughly > equivalent to a typeclass instance
Hi Phillip, I don't know much about Haskell, but this sounds roughly right. As I understand it, a Concept describes what interface/capabilties a type should have, while a Model describes a mapping of types onto Concepts for types that don't fit automatically. For instance, a Model can be used to give all raw pointer types a value_type typedef member to allow them to fit the Iterator Concept. > > One of the papers on the site mentions something called "concept-based > overloading", which if I'm reading it correctly, is the idea that's at the > heart of this thread; i.e., it should be possible to say that a particular > implementation of one operation is dependent upon the availability of an > implementation of some other operation. > Yes, C++ previously had compilicated ways of "overloading" template implementations based on things like boosts enable_if (you don't want to know!), but Concepts allow this to be done in a clear and obvious way. A dynamic version of concepts (I guess a combo of multi-methods and adaptation) would be great for Python, but it's hard to see how it could be done simply and efficiently. Cheers, Ben > _______________________________________________ > Python-3000 mailing list > Python-3000@python.org > http://mail.python.org/mailman/listinfo/python-3000 > Unsubscribe: http://mail.python. > org/mailman/options/python-3000/python%40theyoungfamily.co.uk > _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com