cast(immutable) vs extra variable

bearophile bearophileHUGS at lycos.com
Thu Sep 19 13:19:35 PDT 2013


Jonathan M Davis:

> All in all, I think that it's pretty much always a bad idea to 
> have a struct
> with const or immutable members. It's just begging for 
> problems. Tail-const or
> tail-immutable is fine, because the members themselves aren't 
> const or
> immutable (just what they refer to), but having them be 
> directly const or immutable is a bad idea IMHO.

The Rust language has avoided this problem, you can copy struct 
instances with const fields. But you can't update their const 
fields.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list