On Sunday, 9 September 2018 at 08:14:41 UTC, rikki cattermole
wrote:
Are you aware that a string is just an alias of
immutable(char)[]?
Yes, I'm aware of that. But it's the same, for example, with just
one char. "immutable char" vs "const char*".
Or int, or any other data type. As of my current understanding
"char" will create a new variable and copy the content of the
original to the new variable. "char*" will just use the pointer.
And "const char*" is good for when not modifying. But I also can
achieve the same using "immutable char". But I'm not sure when
better using "immutable char".
In C I would rather use a const pointer. But since I just started
learing D I'm not so sure because there are so many ways.