Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-28 13:53:08


At Tue, 28 Sep 2010 10:12:29 -0700,
Steven Watanabe wrote:
>
> AMDG
>
> On 9/27/2010 11:28 PM, David Abrahams wrote:
> > At Mon, 27 Sep 2010 18:49:06 -0700, Steven Watanabe wrote:
> >>> ...but I'm not even sure there is a problem yet, even though I was one
> >>> of the first people to recognize that concepts clash with TMP as
> >>> practiced today. The question is whether a different approach can
> >>> accomplish the same ends. As far as I'm concerned, that's still an
> >>> open question.
> >> Until someone finds a way, it might as well not be possible.
> > That might be a little like saying, "until someone demonstrates that
> > you can write the Sieve of Eratosthenes algorithm in BASIC, it might
> > as well not be possible." At some level, all programming paradigms
> > are equivalent.
>
> You, yourself, just said that it was an open question.

Yes. That doesn't make it as good as impossible. There are things
that are known/proven to be impossible, you know.

> Would you describe writing the sieve of Eratosthenes
> in BASIC as an open question? FWIW, I'm sure that
> there /exists/ another way to do the things that we do
> now with TMP, which will work with concepts. I'm not
> at all convinced that it won't have more problems than
> current TMP.

Me neither; I think we just don't know. AFAIK nobody has tried very
hard to look for concepts-compatible solutions to the same problems we
currently use TMP for.

> >>>> Thus, once
> >>>> you actually instantiate the template, there can be no errors
> >>>> whatsoever. We don't apply this level of type-checking to
> >>>> runtime code, because it's simply impractical to guarantee.
> >>> I think you mean we don't apply this level of runtime checking to
> >>> runtime code?
> >> No, I really do mean type checking.
> > I don't see how that's consistent with your analogy. When I map back
> > into the runtime world, why doesn't type checking become runtime
> > (value) checking again?
>
> This would be true without C++0x concepts. Half of concepts
> is type checking the bodies of templates when they are defined.
> These checks are equivalent to ordinary type checking in the
> runtime world.

If you say so. I still don't see how. [I think you mean "analogous,"
not "equivalent," right? They're certainly not substitutable for one
another.]

> The problem is that concepts force all checks into this realm.

I don't know what you're getting at, but it might be related to this:
the fact that concepts do early checking is problematic for many of
our current TMP idioms, which rely on having checks only at
instantiation time. For example, foo<mpl::_1> couldn't be written if
foo were a constrained template, unless mpl::_1 just happened to
satisfy its requirements.

Anyway, yeah, that's a clash. But maybe in a "concepts" world we
wouldn't want to do that in the first place.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk