Article: Why Const Sucks
Radu
void at null.pt
Tue Mar 6 10:02:10 UTC 2018
On Monday, 5 March 2018 at 10:57:35 UTC, Jonathan M Davis wrote:
> Here's something I wrote up on const:
>
> http://jmdavisprog.com/articles/why-const-sucks.html
>
> I suppose that it's not exactly the most positive article, but
> I feel that it's accurate.
>
> - Jonathan M Davis
Spot on article, and touches some of my pain points when working
with const/immutable structs.
Recently I tried to create a ref-counted immutable struct, oh
boi...
This later use case is of tremendous value for safe concurrent
code that's @nogc. Unfortunately I couldn't find a way to make it
work efficiently and in the same time not look like a disgusting
hack.
I suspect a possible solution is to allow immutable(const)
postblit overloads as well as immutable dtors that will act as an
escape hatch for unsafe work and in the same time provide hints
that you are operating on an immutable(const) this.
More information about the Digitalmars-d-announce
mailing list