<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I don’t want to weigh in for/against any particular Clang proposal, but FWIW regarding this:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> Not all demands must be satisfied.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>True, but in this case…<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> Other languages (I'm looking at Java) have reflection without expression reflection<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>… IMO we already know that we will need statement and expression reflection, to enable uses like autodiff. For example, in the ML field I’ve encountered C++ developers who would prefer to use C++ because of its AOT compilation performance, but who of have switched to other languages such as Julia primarily because of compile-time autodiff (and more generally for the broader class of AI/ML transformations that includes autodiff) where today in C++ doing it by hand-coding the derivative function greatly slows down the experimentation phase of an ML project… which otherwise would actually be faster with AOT C++.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>At least one of the proof-of-concept C++ reflection implementations (Circle) already support statement/expression reflection and autodiff.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For statements and expressions, my impression is that reflection is pretty straightforward to specify (here’s another meta::info API) and the primary thing to watch for is that the current proposals for injection (generated code, generative programming) will extend well to statements and expressions, again using autodiff as a litmus test example of what we want to be able to express.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Herb<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> cfe-dev <cfe-dev-bounces@lists.llvm.org> <b>On Behalf Of </b>David Blaikie via cfe-dev<br><b>Sent:</b> Tuesday, November 12, 2019 11:42 AM<br><b>To:</b> David Rector <davrec@gmail.com><br><b>Cc:</b> Clang Dev <cfe-dev@lists.llvm.org><br><b>Subject:</b> Re: [cfe-dev] Reflection/metaparsing implem<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Tue, Nov 12, 2019 at 6:04 AM David Rector <<a href="mailto:davrec@gmail.com">davrec@gmail.com</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal>Fair enough.  <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>As I say in my readme, I recommend those who need full reflection facilities — up to their class templates, down to the individual IfStmts etc. in their function defs — to use my implementation and simply isolate dependencies on future standards into their own helper functions.  You can do everything now!  No need to complain to or pressure Andrew (who has done some extraordinary work by the way) about what isn’t yet reflected.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>*Eventually* the standard will support reflecting everything, years hence, whatever anyone says now.  The demands will just never stop until everything is reflected.<o:p></o:p></p></div></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Not all demands must be satisfied. Other languages (I'm looking at Java) have reflection without expression reflection, for example, so far as I know.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal> Start writing your algorithms now, switch your helper functions to whatever standards they decide later.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>Regarding parallel naming I think we’re talking about different things — what we’re doing now IS a parallel naming structure.  meta::is_constexpr(reflinfo) is a parallel of FunctionDecl::isConstexpr() etc.  A full parallel structure of every property is what we’re looking at building.  If everyone’s looked hard at that eventuality and are okay with maintaining that, then I suppose I have no cause to complain — maybe it’s not as hard as I imagine.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal>On Nov 12, 2019, at 8:01 AM, Andrew Sutton <<a href="mailto:asutton.list@gmail.com" target="_blank">asutton.list@gmail.com</a>> wrote:<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><p class=MsoNormal><o:p> </o:p></p></div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><p class=MsoNormal>I argue the standards should be based on the clang AST.  Clean it up first of course — and yes that alone would be extraordinarily difficult.  But it’s also very difficult to build a gigantic parallel naming system for reflection properties.  And then to maintain it long term…<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Best to look hard at what lies ahead, and bite the bullet now.  Clean up the AST, define the standard via it.  (And c’mon we all know those AST nodes have a lot of flab to go with all their muscle; clang would benefit too after we all finish grumbling about the changes.)  Other compilers can do a parallel naming system or adjust their own ASTs to match clang’s naming system — doesn’t need to add any work for them.<o:p></o:p></p></div></div></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>This is a non-starter for standardization. There are significant and generally incompatible differences in the internal representations of C++ among the different vendors and no will to standardize or even informally adopt a common representation. Even if there were interest in doing so, the engineering cost would be prohibitive, as it would essentially require gutting and rewriting huge swaths of the compiler (and in GCC's case, possibly the middle-end). Parallel naming is also unlikely because of memory requirements.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>You have the same problem with compiled module interfaces, which serialize the internal representation.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Andrew<o:p></o:p></p></div></div></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></blockquote></div></div></div></div></body></html>