aarti_pl <[email protected]> wrote:

Well, I don't get it...

IMHO .dup makes mutable copy of data (so copy of "test") in mutable area of memory. And it should mean that every pointer points to different area of memory...

Am I wrong?

You're mostly right. However, this happens at compile time, so the mutable
data is mutable no longer once its been stored in the executable. IOW,
"Test".dup is executed once at compile time, and the result stored in
Test.init. Then, at runtime, Test.init is copied onto each new instance of
the struct/class. "Test".dup is not executed at runtime.

As Lutger pointed out, this smells of a bug. Sadly, fixing that bug would
not overcome the problem of having no default constructors for structs.

--
Simen

Reply via email to