Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Sep 2024 10:29:06 -0400
From:      Jan Knepper <jan@digitaldaemon.com>
To:        David Chisnall <theraven@freebsd.org>, Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        Warner Losh <imp@bsdimp.com>, Kristof Provost <kp@freebsd.org>, Alan Somers <asomers@freebsd.org>, Dmitry Salychev <dsl@freebsd.org>, FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: The Case for Rust (in any system)
Message-ID:  <51c6d673-fb78-4c9e-a01f-427a3cbbc1d7@digitaldaemon.com>
In-Reply-To: <202DD893-B152-4B38-AE9B-862E08785396@freebsd.org>
References:  <202409082111.488LBTtI074660@critter.freebsd.dk> <202DD893-B152-4B38-AE9B-862E08785396@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 9/9/24 03:01, David Chisnall wrote:
> On 8 Sep 2024, at 22:11, Poul-Henning Kamp<phk@phk.freebsd.dk>  wrote:
>> Warner Losh writes:
>>
>>> I did C++ in the kernel in the 4.x->7-current time frame.
>> The logical progression of C++ adoption would start with using a C++
>> compiler as a better C compiler.
> C permits implicit casts from void*, C++ doesn’t. The last codebase I worked on that had gone through this transition was littered with implicit casts which made it hard to read. At a minimum, I’d want to add an always-inline templates wrapper around malloc that did the right thing, if not an explicit move to new/delete.
I have always found this to be a benefit.
Where C just casts away, C++ requires to 'review' to cast and show via a 
*_cast < ... > mechanism that the 'cast' is actually meant that way.
> C++ places type and value names in the same namespace. There are some corner cases where a structure and a variable have the same name and sizeof gives different results in C and C++ modes.
>
>
I have never found this to be a problem. They are indeed (rare) corner 
cases. (I also think I have noticed that particular C++ compilers at 
least warns when this might happen).

However, I do think if compilation would be moved from C compiler to C++ 
compiler that particular coding standards have do be defined and followed.
The proper standard being set and followed will prevent issues.

[-- Attachment #2 --]
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    On 9/9/24 03:01, David Chisnall wrote:<br>
    <blockquote type="cite"
      cite="mid:202DD893-B152-4B38-AE9B-862E08785396@freebsd.org">
      <pre class="moz-quote-pre" wrap="">On 8 Sep 2024, at 22:11, Poul-Henning Kamp <a class="moz-txt-link-rfc2396E" href="mailto:phk@phk.freebsd.dk">&lt;phk@phk.freebsd.dk&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
Warner Losh writes:

</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">I did C++ in the kernel in the 4.x-&gt;7-current time frame.
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">
The logical progression of C++ adoption would start with using a C++
compiler as a better C compiler.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
C permits implicit casts from void*, C++ doesn’t. The last codebase I worked on that had gone through this transition was littered with implicit casts which made it hard to read. At a minimum, I’d want to add an always-inline templates wrapper around malloc that did the right thing, if not an explicit move to new/delete.</pre>
    </blockquote>
    I have always found this to be a benefit.<br>
    Where C just casts away, C++ requires to 'review' to cast and show
    via a *_cast &lt; ... &gt; mechanism that the 'cast' is actually
    meant that way.
    <blockquote type="cite"
      cite="mid:202DD893-B152-4B38-AE9B-862E08785396@freebsd.org">
      <pre class="moz-quote-pre" wrap="">C++ places type and value names in the same namespace. There are some corner cases where a structure and a variable have the same name and sizeof gives different results in C and C++ modes.


</pre>
    </blockquote>
    I have never found this to be a problem. They are indeed (rare)
    corner cases. (I also think I have noticed that particular C++
    compilers at least warns when this might happen).<br>
    <br>
    However, I do think if compilation would be moved from C compiler to
    C++ compiler that particular coding standards have do be defined and
    followed.<br>
    The proper standard being set and followed will prevent issues. <br>
    <br>
  </body>
</html>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51c6d673-fb78-4c9e-a01f-427a3cbbc1d7>