[Issue 18417] Make const and immutable postblit constructors illegal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 12 12:25:44 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18417

--- Comment #3 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to anonymous4 from comment #2)
> Dunno, they can still refer global data?
> ---
> int called;
> struct A {
> 	this(this) immutable { called++; }
> }
> ---

And what would the point of that be? The entire point of a postblit constructor
is to define how a struct is copied. That has nothing to do with global data.
And it's impossible for an immutable or const postblit constructor to be called
in the first place. If you try and declare a const or immutable postblit
constructor, you just end up with compilation errors, because they don't work -
and they can't work, not for what the purpose of a postblit constructor is.
Making them illegal would just make it so that the error is clear as to what's
going on, whereas right now, they tend to be confusing and cryptic to anyone
who doesn't understand what's going on.

--


More information about the Digitalmars-d-bugs mailing list