|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54169 - sandbox/committee/LWG/proposals
From: dave_at_[hidden]
Date: 2009-06-21 23:02:26
Author: dave
Date: 2009-06-21 23:02:26 EDT (Sun, 21 Jun 2009)
New Revision: 54169
URL: http://svn.boost.org/trac/boost/changeset/54169
Log:
These are my suggested edits.
Text files modified:
sandbox/committee/LWG/proposals/Intentional | 149 ++++++++++++++++-----------------------
1 files changed, 62 insertions(+), 87 deletions(-)
Modified: sandbox/committee/LWG/proposals/Intentional Concept Mapping.html
==============================================================================
--- sandbox/committee/LWG/proposals/Intentional Concept Mapping.html (original)
+++ sandbox/committee/LWG/proposals/Intentional Concept Mapping.html 2009-06-21 23:02:26 EDT (Sun, 21 Jun 2009)
@@ -38,34 +38,32 @@
<h2>Introduction</h2>
- <p>Uses of C++0x concept maps include:</p>
+ <p>A C++0x concept map can be useful (among other things) as:</p>
<ul>
- <li>Declaring the intention that a class models a concept, expressed in
- code rather than in documentation.<br />
- </li>
+ <li>A declaration to the compiler of the intention that a class models a
+ concept, expressed in code rather than in documentation.</li>
- <li>Declaring to users and maintainers of the type that modeling the
+ <li>A declaration to users and maintainers of the type that modeling the
concept is part of the type's public interface and not just happenstance;
i.e. it is a property that can be counted on and must be preserved as the
code evolves.</li>
- </ul>
- <p>As of CD1, this is expressed with concept maps that are often empty:</p>
+ <li>A tool for the interactive model development that causes the compiler
+ to prompt the author for all required structural elements.</li>
+ </ul>
- <blockquote>
- <pre>
+ <p>As of CD1, concept maps used for this purpose are often empty:</p>
+ <pre>
class Endian
{
...
};
-</pre>
- <pre>
+
concept_map std::Regular<Endian> {}
concept_map std::StandardLayoutType<Endian> {}
concept_map std::TrivialType<Endian> {}
</pre>
- </blockquote>
<p>Although this formulation is technically sufficient and will ensure the
type models the concepts, it has some problems:</p>
@@ -73,99 +71,88 @@
<ul>
<li>The location of the concept maps after the class definition subverts
self-documentation, particularly for large classes, negating some of the
- value as documentation to users and maintainers.<br />
- </li>
+ value as documentation to users and maintainers.</li>
- <li>Specifying the concept maps after the class definition tends to push
- this important activity until later in the development cycle, yet
- from a design and testing standpoint it best occurs early on in the
- development cycle.<br />
- </li>
+ <li>The location of the concept maps after the class definition tends to
+ tends to push the important activity of constraining the class until
+ later in the class' development cycle, but it best occurs early (probably
+ first).</li>
- <li>The empty concept maps are excessively verbose.</li>
+ <li>Empty concept maps are excessively verbose.</li>
</ul>
- <p>This paper proposes that the above could also be written as:</p>
-
- <blockquote>
- <pre>
+ <p>This paper proposes that the above code could also be written as:</p>
+ <pre>
class Endian -> std::Regular, std::StandardLayoutType, std::TrivialType
{
...
};
</pre>
- </blockquote>
<h2>Syntax</h2>
<p>The proposed wording uses <code>-></code> as a syntax marker for the
beginning of the list of concepts to be mapped. The authors are not wedded
- to <code>-></code> , and considered several alternate keyword and
+ to <code>-></code>, and considered several alternate keyword and
punctuation possibilities.</p>
- <p>The first keyword considered was <code>requires</code>, but it was
- rejected because when you write:</p>
-
- <blockquote>
- <pre>
+ <p>We did consider using <code>requires</code>, but it was rejected on the
+ grounds that it would make a <code>concept_map</code> look too much like a
+ requires clause in a region of code where either could appear, but a
+ <code>concept_map</code> is fundamentally different from a
+ <code>requires</code> clause. When you write:</p>
+ <pre>
template <typename X>
requires<EqualityComparable<X> >
class Y
{
...
};
-</pre>
- </blockquote>
-
- <p>you're just constraining X, nothing more. It's pure requirement
- checking. When you write:</p>
-
- <blockquote>
- <pre>
+</pre>you're just constraining X, nothing more. It's pure requirement
+checking. However, when you write:
+ <pre>
template <typename X>
class Y -> EqualityComparable
{
...
};
-</pre>
- </blockquote>
-
- <p>you're generating a concept map for all specializations of Y, with all
- that that implies (e.g. generation of defaults, Y<T> can be used
- where EqualityComparable is required, etc):</p>
-
- <blockquote>
- <pre>
-// implied by the above
+</pre>you're generating a concept map for all specializations of
+<code>Y</code>, with all that that implies (e.g. generation of defaults,
+Y<T> can be used where EqualityComparable is required, etc):
+ <pre>
+// generated by the above
template <typename T>
concept_map EqualityComparable<Y<T> > { };
</pre>
- </blockquote>
-
- <p>A concept_map is fundamentally different from a requires clause in other
- ways, too: the former can only occur in unconstrained contexts while the
- latter can only occur in constrained ones.</p>
<p>We welcome syntax suggestions from the committee.</p>
<h2>Motivation</h2>
<p>The critical motivation for this proposal is the desire to be able to
- say "my type models concepts XXX, YYY, and ZZZ, and is broken if it doesn't
- do that", and do that in such a way that users and maintainers understand
- that this is part of my type's public interface and not just
- happenstance.</p>
-
- <p>This proposal is not replacement for concept maps; we view concept maps
- - even empty ones - as meeting critical needs. We wish to make empty
- concept maps more convenient and less verbose, not replace them
- entirely..</p>
-
- <p>The motivating problem of not being able to say what we mean in the
- obvious place is not solved by making more concepts <code>auto</code> or
- making <code>auto</code> the default. Those are important issues, but are
- orthogonal to the intentional concept mapping concerns of this
- proposal.</p>
+ say "my type models concepts XXX, YYY, and ZZZ, and please tell me if I get
+ it wrong (structurally)", and to do that in such a way that users and
+ maintainers understand that this is part of my type's public
+ interface and not just happenstance.</p>
+
+ <p>This proposal is not replacement for concept maps; we view
+ concept maps—even empty ones—as meeting critical
+ needs. We wish to make empty concept maps more convenient, more
+ expressive, and less verbose in the common case where one is
+ intentionally creating a model of a known concept, however empty
+ <code>concept_map</code>s will still be needed for post-hoc
+ adaptation of types to concepts, an important function
+ of <code>concept_map</code>s in general.</p>
+<!--
+ <p>The underlying problem of not being able to say what we mean
+ concisely—and in the obvious place—is not solved by
+ making more concepts <code>auto</code> or making <code>auto</code>
+ the default. Those are important issues, but are orthogonal to the
+ intentional concept mapping concerns of this proposal.</p>
+-->
+ <!-- Beman, I'm not sure I want to bring that argument up; are you?
+ It seems a bit like inviting trouble, and I'd like to save trouble
+ for my other paper ;-) -->
<h2>Proposed Wording</h2>
@@ -233,26 +220,21 @@
nested-name-specifier<sub>opt</sub> concept-name</i></p>
</blockquote>
- <p>A <i>concepts-clause</i> contains a list of concepts to map to. A
- concept is mapped to for each <i>mapped-concept</i> as if by a
+ <p>A <i>mapped-concept-clause</i> contains a list of concepts to map to.
+ A concept is "mapped to" for each <i>mapped-concept</i> as if by a
<code>concept_map</code>([concept.map]). The <code>concept_map</code>
acts as if appears immediately after the class being defined, and is
equivalent to:</p>
-
- <blockquote>
- <pre>
+ <pre>
concept_map <i>Concept</i><<i>Class</i>> {};
</pre>
- </blockquote>
<p>where <i><code>Concept</code></i> is the <i>mapped-concept</i>, and
<i><code>Class</code></i> is the class where the
<i>mapped-concept-clause</i> appears.</p>
<p><i>[Example:</i></p>
-
- <blockquote>
- <pre>
+ <pre>
template <typename X>
class Y -> EqualityComparable
{
@@ -260,15 +242,11 @@
};
</pre>
- <p>Generates a concept map for all specializations of Y, with all that
- that implies (e.g. generation of defaults, Y<T> can be used where
- EqualityComparable is required, etc):</p>
- <pre>
-// implied by the above
+ <p>The above implicitly generates the following concept map:</p>
+ <pre>
template <typename T>
concept_map EqualityComparable< Y<T> > {};
</pre>
- </blockquote>
<p><i>--end example]</i></p>
</blockquote>
@@ -279,8 +257,5 @@
this proposal, often with syntax using the <code>requires</code> keyword.
Jerry Schwarz, in committee message c++std-lib-23459, suggested syntax that
mimics inheritance.</p>
- <hr />
-
- <p> </p>
</body>
</html>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk