<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">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…<div class=""><br class=""><div class="">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.</div><div class=""><br class=""></div><div class="">Dave</div><div class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 11, 2019, at 12:49 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div dir="ltr" class="gmail_attr">On Mon, Nov 11, 2019 at 8:43 AM David Rector via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="overflow-wrap: break-word;" class=""><div class="">Please enjoy this clang 7.0.0 fork:</div><div class=""><br class=""></div><a href="https://github.com/drec357/clang-meta" target="_blank" class="">https://github.com/drec357/clang-meta</a><div class=""><br class=""></div><div class="">This reflection implementation reflects just about the entire clang AST, and lets you use clang syntax/names in *regular, non-clang* C++ code:</div><div class=""><br class=""></div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class="">namespace ns { class MyClass { float f; }; }</div><div class="">constexpr {</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>ce_assert(reflexpr(ns)->isInline());</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>ce_assert(!reflexpr(ns)->isAnonymousNamespace())</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>FOR ( (Decl *D) : reflexpr(ns::MyClass)->decls()) {</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>if (auto_ FD = dyn_cast<FieldDecl>(D))</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>FD->dump();</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>}</div><div class=""><span style="white-space: pre-wrap;" class=""> </span></div><div class=""><span style="white-space: pre-wrap;" class=""> </span>//As for meta-parsing:</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>__queue_metaparse("static const int i = ");</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>constexpr int ival = __metaparse_expr(__concatenate("3", 2+2), int);</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>__queue_metaparse(jval);</div><div class=""><span style="white-space: pre-wrap;" class=""> </span>__queue_metaparse(";")</div><div class=""><br class=""></div><div class="">} // queued metatparses performed here…</div><div class=""><br class=""></div><div class="">static_assert(i = 34);</div></blockquote><div class=""><br class=""></div><div class="">Plus you can define clang-style diagnostics and FixItHints, using reflected SourceLocations, in your regular, non-clang code.</div><div class=""><br class=""></div><div class="">Please adapt to any uses you see fit! I would love to see this way in the C++ standards, much more general and low-maintenance than the proposals I’ve seen,</div></div></blockquote><div class=""><br class="">One quick caveat: If it's general and lower maintenance by exposing Clang's AST directly, that is probably a significant deterrent to this being standardized - Clang's AST changes and it's not the same as other compilers ASTs, so generalizing this across compilers and across time might be quite difficult.<br class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="overflow-wrap: break-word;" class=""><div class="">but I sense that will be an uphill battle. Please let me know if you would support this way of doing reflection/metaprogramming, or have suggestions on how to proceed.</div><div class=""><br class=""></div><div class="">David Rector</div></div>_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a><br class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></blockquote></div></div></blockquote></div><br class=""></div></div></div></body></html>