|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-11-14 14:21:28
Brian McNamara <lorgon_at_[hidden]> writes:
> On Fri, Nov 14, 2003 at 11:54:40AM -0500, Brian McNamara wrote:
>> On Fri, Nov 14, 2003 at 08:15:03AM -0800, Mat Marcus wrote:
>> > structural conformance? How do things work in practice in Haskell?
>>
>> (2) All conformance must be declared. Everything, even stuff like
>> "int" is a "EqualityComparable" and a "LessThanComparable". It
>> is not as bad at it sounds.
>
> To be clear: _in_Haskell_ it's not as bad as it sounds. As Dave has
> recently pointed out, it's more painful to "say the same thing" in C++,
> since there are no language mechanisms designed to help us say it.
I think I was pointing out that it's a pain in Haskell ;-)
Anyway, having never used Haskell I'm going to make a few more
pronouncements ;->. I think the biggest problem with Haskell's
approach is the lack of type associations that aren't declared in the
conformance declaration. In other words, every time you make a new
C++ iterator type, you'd need to say something like:
"Foo is an iterator, int is its value_type, int& is its reference
type, std::ptrdiff_t is its difference_type,
std::random_access_iterator_tag is its category, and int* is its
pointer type"
Have I got that wrong? Naturally you do have to make the same
associations in C++, but you have the advantage of conveniently
nesting the types or deriving from some class which generates them
because of C++'s use of structural conformance.
A related issue: because of the separate compilation model, it seems
as though any metaprogramming done inside a generic function ends up
getting exported and "done outside" somehow.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk