Hi there,

I'm an experient C++ developer and am trying to switch to / learn
D. What I've seen so far is mostly quite straight forward and
VERY nice.

There's only one catch so far for me for which Googling has only
found the discouraging answer of: It can't be done in D.

I have two classes A and B. Each object of class A is associated
with a particular object of class B. This association is not
supposed to change throughout the lifetime of the object of A.

How am I supposed to express this in D, given that D's const is
too strong for this? I don't need any guarantees from the const
that can be used for thread safety or parallelisation. All I need
is the compiler not letting me change the reference to the B
object inside the A object.

Does D have some way of expressing this?

Or has D really done away with the MOST important use case of
const (preventing developer mistakes! Not optimization.)

Cheers,
Seb

Reply via email to