On Wednesday, 4 December 2019 at 22:29:13 UTC, kerdemdemir wrote:
Unfortunately I am not yet good with D to answer your question .
But Ali Çehreli made some comparesions with C++.
https://dconf.org/2013/talks/cehreli.pdf
And I think you will find the answers of your questions in it also.

Thanks. He didn't really compare to modern C++, but I appreciate the pointer.

Seems to me that immutable references are primarily useful when calling a function with two references to an array. So you can be certain that the read-only reference will not be modified within the function (if both parameters point to the same array as they can with a const reference).

Also, constexpr in C++ is a CTFE constraint and not a type, so not fully comparable to immutable, but same effect... perhaps. Not sure how smart compilers are in this regard.

So immutable references i D is basically the same as const-references with restrict in C/C++ (non-standard, but common C++)?


Reply via email to