On 29/05/13 19:40, monarch_dodra wrote:

The problem is that you are missing a FUNDAMENTAL difference between C++
and D. C++'s const merely says: "Though shalt not modify this value",
whereas D's means "This object's value WILL remain constant, until the
end of time, and under no circumstance can it ever be modified. Oh. And
so will everything it references".

More likely C constness but yes I am still learning D. I suspect that a lot of my D code currently looks like C code using D syntax. As I learn more I'll go back and change the code to be more D like than C like (especially as this usually leads to major simplifications).

I'm also starting to suspect that my understanding of how C arrays are passed as arguments to functions is affecting my desire to use const when passing them in and this may be misguided. I've been trying to find out how non ref array arguments are passed to functions in D but can't find any documentation on it. If doing that is not much less efficient than passing by ref (and isolates the external representation of the array from anything I do) then I can stop using ref and the problem goes away.

Peter

Reply via email to