Thread overview | |||||
---|---|---|---|---|---|
|
April 22, 2010 What's the diff between immutable and const? | ||||
---|---|---|---|---|
| ||||
What's the diff between immutable and const? |
April 22, 2010 Re: What's the diff between immutable and const? | ||||
---|---|---|---|---|
| ||||
Posted in reply to XCPPCoder | XCPPCoder <xcelsior@jupitor.com> wrote: > What's the diff between immutable and const? Basically, const means 'I can't change this', while immutable means 'nobody will change this'. The idea is that const is a guarantee given by a function, while immutable is a guarantee for the whole program. Also, immutable opens up optimization possibilities, as you can safely assume the data is not going to change under you. That means read once, and no locks necessary. -- Simen |
April 22, 2010 Re: What's the diff between immutable and const? | ||||
---|---|---|---|---|
| ||||
Posted in reply to XCPPCoder | XCPPCoder wrote: > What's the diff between immutable and const? Very shortly: immutable means "never changes", "const" means "may not be changed through this reference". Some more information: http://www.digitalmars.com/d/2.0/const3.html Ali |
Copyright © 1999-2021 by the D Language Foundation