[PATCH] Introduce a section to the programmers manual about type hierarchies, polymorphism, and virtual dispatch.

Sean Silva chisophugis at gmail.com
Tue Jan 27 04:11:30 PST 2015


I really like it. Some minor suggestions.


================
Comment at: docs/ProgrammersManual.rst:2505-2506
@@ +2504,4 @@
+
+An alternate implementation strategy for the second use case which should be
+preferred within LLVM is to that of generic programming. For example, a template
+over some type parameter ``T`` can be instantiated across any particular
----------------
Somewhere in this paragraph it might be worth mentioning that the buzz-words "compile-time duck typing" or "static polymorphism" is sometimes used to describe this.

================
Comment at: docs/ProgrammersManual.rst:2507-2508
@@ +2506,4 @@
+preferred within LLVM is to that of generic programming. For example, a template
+over some type parameter ``T`` can be instantiated across any particular
+implementation that conforms to the interface. A good example here is the
+highly generic properties of any type which models a node in a directed graph.
----------------
I would suggest making a connection with "concepts", e.g.  `... that conforms to the interface (sometimes called a "concept").`

================
Comment at: docs/ProgrammersManual.rst:2519-2527
@@ +2518,11 @@
+
+#. `Sean Parent's Papers and Presentations
+   <http://github.com/sean-parent/sean-parent.github.com/wiki/Papers-and-Presentations>`_
+   - A Github project full of links to slides, video, and sometimes code.
+#. `Value Semantics and Concepts-based Polymorphism
+   <http://www.youtube.com/watch?v=_BpMYeUFXv8>`_ - The C++Now! 2012 talk
+   describing this technique.
+#. `Inheritance Is The Base Class of Evil
+   <http://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil>`_
+   - The GoingNative 2013 talk describing this technique.
+
----------------
I think it would be useful to give explicit guidance to the reader as to which of these to look at first. I think it's reasonable to get up to speed on this pattern from these resources from a single ~30min video. It's not clear to the reader from this list whether getting up to speed on this pattern is something that they can click through one of these videos and watch it while eating a sandwich, or whether it is more weekend-scale.

When I encountered this stuff for the first time, IIRC I sort of skipped through the C++Now! 2012 and that really got my interest, then I watched the GoingNative 2013 talk and finally skimmed through some of the resources linked from the github. Based on my anecdotal experience, I would probably favor calling out the GoingNative 2013 talk as "watch this for a quickstart".

================
Comment at: docs/ProgrammersManual.rst:2538-2539
@@ +2537,4 @@
+
+If you do need to introduce a type hierarchy, we often prefer to use explicitly
+closed type hierarchies with manual tagged dispatch rather than the open
+inheritance model and virtual dispatch that is more common in C++ code. This is
----------------
Probably want a link to http://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html . You may want to use the catch-phrase "LLVM-style RTTI" somewhere here as well.

Also feel free to make changes to HowToSetUpLLVMStyleRTTI to better fit into the context of the discussion you're adding here.

http://reviews.llvm.org/D7191

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list