Re: How do I copy struct having immutable pointer member when enabled DIP1000?

2020-08-31 Thread outlandkarasu via Digitalmars-d-learn
On Monday, 31 August 2020 at 05:46:45 UTC, ag0aep6g wrote: `ref` kind of implies `scope` [1]. You don't need to type it out. When you do type out `scope ref const(Price)`, the `scope` actually doesn't apply to the `ref` but to the pointers in `Price` (whereas the `scope` in `scope

Re: How do I copy struct having immutable pointer member when enabled DIP1000?

2020-08-30 Thread ag0aep6g via Digitalmars-d-learn
On 31.08.20 06:24, outlandkarasu wrote: I thought that I cannot make non-scope `ref` parameters from `scope` array references. But I found It allowed currently. [...] enum Currency : string {     USD = "USD", EUR = "EUR", GBP = "GBP", JPY = "JPY", } struct Instrument {     Currency bid;   

Re: How do I copy struct having immutable pointer member when enabled DIP1000?

2020-08-30 Thread outlandkarasu via Digitalmars-d-learn
On Sunday, 30 August 2020 at 16:33:58 UTC, ag0aep6g wrote: On 30.08.20 17:24, outlandkarasu wrote: enum Tag { tag = "tag" } struct A { Tag tag; } A createA() @safe {     scope a = A(Tag.tag);     // Error: scope variable a may not be returned     return a;     // NG     //

Re: How do I copy struct having immutable pointer member when enabled DIP1000?

2020-08-30 Thread ag0aep6g via Digitalmars-d-learn
On 30.08.20 17:24, outlandkarasu wrote: enum Tag { tag = "tag" } struct A { Tag tag; } A createA() @safe {     scope a = A(Tag.tag);     // Error: scope variable a may not be returned     return a;     // NG     // return A(a);     // return A(a.tag); } [...] I