Title: Modified C++<p>Inspired by the paper &quot;Some Were Meant for C&quot; by Stephen Kell, I decided to show that it&#x27;s possible to iterate C++ to be safer, more explicit, and less error-prone.<p>Here&#x27;s a possible starting point: I didn&#x27;t invent a new language or compiler, but took the world&#x27;s best compiler, clang, and modified it to begin iterating towards a new furture of C++. Naming things is hard, so I call this &#x27;Modified C++&#x27;. Some of the following could be implemented as tooling in a linter or checker, but the idea is to update the compiler directly. I also wanted to learn more about clang. This compiler needs a flag to enable&#x2F;disable this functionality so that existing library code can be used with a &#x27;diagnostic ignored&#x27; pragma.<p>You can build clang using the normal non-bootstrap process and you&#x27;ll be left with a clang that compiles C++ but with the following modifications:<p><pre><code>     - All basic types (excluding pointers and references) are const by
     default and may be marked &#x27;mutable&#x27; to allow them to be changed after
     declaration
     - Lambda capture lists must be explicit (no [&amp;] or [=], by themselves)
     - Braces are required for conditional statements, case and default
     statements within switches, and loops
     - Implicit conversions to bool are prohibited (e.g., pointers must be
     compared against nullptr&#x2F;NULL)
     - No goto support
     - Explicit &#x27;rule of six&#x27; for classes must be programmer-implemented
     (default, copy, and move c&#x27;tors, copy and move assignment, d&#x27;tor)
     - No C style casts

</code></pre>
Here&#x27;s an example program that&#x27;s valid in Modified C++:<p><pre><code>    mutable int main(int, char**)
    {
      mutable int x = 0;
      return x;
    }


    Here&#x27;s another that will fail to compile:


    mutable int main(int, char**)
    {
      int x = 1;
      x = 0;  &#x2F;&#x2F; x is constant
      return x;
    }

</code></pre>
I&#x27;d like your feedback. Future changes I&#x27;m thinking about are:<p><pre><code>     - feature flag for modified c++ to enable&#x2F;disable with &#x27;diagnostic ignored&#x27;
     pragma, to support existing headers and libraries
     - support enum classes only
     - constructor declarations are explicit by default
     - namespaces within classes
     - normalize lambda and free function syntax
     - your ideas here</code></pre>
Upvote: