D has the same memory model as C++
Paul Backus
snarwin at gmail.com
Wed Aug 11 20:37:21 UTC 2021
On Wednesday, 11 August 2021 at 19:38:38 UTC, Tejas wrote:
> On Wednesday, 11 August 2021 at 19:27:34 UTC, Ali Çehreli wrote:
>> On 8/11/21 12:19 PM, Tejas wrote:
>>
>>> Atleast leave some pointers on where to start :(
>>
>> I DuckDuckGo'ed it for you. :)
>>
>> https://en.cppreference.com/w/cpp/language/memory_model
>>
>> Then looked it up at Wikipedia too:
>>
>> https://en.wikipedia.org/wiki/Memory_model_(programming)
>>
>> Ali
>
> I was hoping on material regarding. c++ vs D memory model, not
> C++ model alone. That's the problem. For pure C++, there's even
> the paper by Stroustroup et al. which feels pretty definitive.
>
> That's why I asked here whether anyone could tell me about the
> subtle differences between C++ and D, with regards to memory
> model, or any other features that share surface resemblance,
> but are different underneath.
D's memory model is described on this page of the language spec:
https://dlang.org/spec/intro.html
I'm not super familiar with C++'s memory model, but just from
eyeballing the cppreference page, it looks like the main
difference between the C++ and D memory models is how they handle
access to memory from multiple threads. In particular, D makes a
distinction between "thread-local memory locations", which may
only be accessed from one thread, and "shared memory locations",
which may be accessed from multiple threads. In C++, any memory
location can be accessed from any thread.
The other big difference is that D's spec does not really define
its terms. What exactly it means for a thread to "access" a
memory location, or for concurrent accesses to be "synchronized",
is never actually explained. For these details, it is *probably*
safe to fill in the blanks with the equivalent definitions from
C++.
More information about the Digitalmars-d-learn
mailing list