Best practices of using const

2019-02-13 Thread envoid via Digitalmars-d-learn
In C++ we have const correctness in some way. A compiler can make optimizations whenever it doesn't find a const_cast and the mutable specifier marks members that aren't a part of the object state. Of course, it's not perfect but one can document their intentions and it's possible to use

Re: Best practices of using const

2019-02-13 Thread Kagamin via Digitalmars-d-learn
D has immutable data, const allows to consume both mutable and immutable data.

Re: Best practices of using const

2019-02-13 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 11:32:46 UTC, envoid wrote: Is there an article that explains best practices of using const in D? Chapter 8 of Andrei Alexandrescu's book The D Programming Language.

Re: Best practices of using const

2019-02-13 Thread Alex via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 11:32:46 UTC, envoid wrote: Is there an article that explains best practices of using const in D? http://jmdavisprog.com/articles/why-const-sucks.html

Re: Best practices of using const

2019-02-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 13, 2019 at 11:32:46AM +, envoid via Digitalmars-d-learn wrote: > In C++ we have const correctness in some way. A compiler can make > optimizations whenever it doesn't find a const_cast and the mutable > specifier marks members that aren't a part of the object state. Of > course,

Re: Where to start with SafeD?

2019-02-13 Thread Mike Franklin via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 22:29:18 UTC, solidstate1991 wrote: When I tried to apply to a position at Symmetry, I've got a criticism from Atila Neves that some of my code relied too much on memcpy, thus making it unsafe. After digging into std.array, I found some function that could

Where to start with SafeD?

2019-02-13 Thread solidstate1991 via Digitalmars-d-learn
When I tried to apply to a position at Symmetry, I've got a criticism from Atila Neves that some of my code relied too much on memcpy, thus making it unsafe. After digging into std.array, I found some function that could possibly replace it to emulate writing in the middle of a file, but at

Re: Best practices of using const

2019-02-13 Thread psycha0s via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 11:32:46 UTC, envoid wrote: Is there an article that explains best practices of using const in D? You can find some information here: https://dlang.org/articles/const-faq.html