const(X) member of Y
Dan
dbdavidson at yahoo.com
Wed Feb 6 13:47:34 PST 2013
On Wednesday, 6 February 2013 at 20:30:40 UTC, Maxim Fomin wrote:
> The fact that bar() does not work and (&bar)() works is
> terrific.
Sorry - but I don't understand what is terrific? Is this sarcasm?
struct X {
this(this) { c = c.dup; }
char c[];
}
(1) What is special about 'struct Y { const(X) x; }' versus 'void
goo(const(X) x) {}'?
Both require a copy of X, but for some reason the 'struct Y {
const(X) x; }' requires the postblit to have signature
'this(this) const {...}'.
Why is this?
(2) Do structs have, or is it planned that structs will have,
true copy constructors (as opposed to postblits)?
(3) I know there have been threads on postblits and const types...
Here is one:
http://forum.dlang.org/thread/CAFDvkcvvL8GxHQB=Rw9pTm-uxOKzNGVQNDv9w5Os3SkQCc=DLQ@mail.gmail.com
and from it:
> Qualified postblits make no sense, given that if
> the object is const or immutable, you _can't_
> alter it without violating the type system. But
> without them, you can't copy const or immutable
> objects which require a postblit. Walter and
> Andrei have stated in the past that they had a
> plan for solving this, but AFAIK, they've never
> actually revealed what it is. My best guess would
> be to introduce copy constructors for const and
> immutable objects, but I don't know. Regardless,
> this is a situation that definitely needs to be
> clarified and properly sorted out.
>
> - Jonathan M Davis
Can someone summarize where this stands?
Is the general thinking that everything is fine now?
More information about the Digitalmars-d
mailing list