Re:The first new build of Circle, a new C++20 compiler, sinc...
by zozbot234 on Monday January 23, 2023 @07:15AM
(#34487931)
C++ templates cannot be reused or rewritten piecemeal in a new language, it's practically impossible. There's a reason why the Rust folks were very careful to separate out generics from the more flexible case of macros (that come in both rewrite-based and procedural varieties).
[ Parent
| on HN ]
Re:The first new build of Circle, a new C++20 compiler, sinc...
by Yoric on Monday January 23, 2023 @09:06AM
(#34488826)
Out of the box, they can't, but I can imagine mitigations for that, if you have robust enough static analysis on your new language. For many cases, it's fairly trivial to generate a piece of .cpp that simply instantiates a template for a specific type and can be linked against.
Of course:
- this doesn't cross library boundaries;
- this assumes robust enough static analysis, which is not possible in the general case, since templates are non-decidable in the general case – so you need to restrict your new language to more reasonable semantics;
- let's not even get started on the interaction between templates and C-style macros – at some point, you need to throw the towel.