When is there a noticable difference when using const values instead of immutable values in a function body? And when should immutable be used instead of const?

f(){
  const x = g();
  immutable y = g();
  ... do stuff with x and y …
}

I'm comparing D to C++ and I get the following mapping:

D:
enum constant = number

C++:
enum : decltype(number) { constant = number }

D:
auto p =  g()

C++:
auto p = g()

D:
const p = g()

C++:
const auto p = g()

D:
immutable p = g()

C++:
hmmm...

Has anyone done a feature by feature comparison with C++? It would be interesting to see what it looks like.

Reply via email to