Re: Unexpected aliasing

2019-11-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 08:15:20 UTC, Basile B. wrote: I'm curious to know what is the equivalent in Pascal that your transpiler fails to translate since Pascal records don't have constructors at all. Maybe you used an old school 'Object' ? Note that Extended Pascal is not exactly

Re: Unexpected aliasing

2019-11-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 11 November 2019 at 21:52:12 UTC, Jonathan M Davis wrote: On Monday, November 11, 2019 12:17:37 PM MST Bastiaan Veelo via Digitalmars- d-learn wrote: [...] I could use some help in rewriting the code below so that arr1 and arr2 each have their own data; ideally with minimal

Re: Unexpected aliasing

2019-11-12 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 07:59:39 UTC, Bastiaan Veelo wrote: On Monday, 11 November 2019 at 20:05:11 UTC, Antonio Corbi wrote: [...] Thanks, Antonio. My problem is that the length of the array should be a built-in property of WrapIntegerArray (immutable in this case); what I'd

Re: Unexpected aliasing

2019-11-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 11 November 2019 at 20:05:11 UTC, Antonio Corbi wrote: Defining and using a constructor for WrapIntegerArray seems to work: void main() { import std.stdio; WrapIntegerArray arr1 = WrapIntegerArray(5); arr1[0] = 42; WrapIntegerArray arr2 =

Re: Unexpected aliasing

2019-11-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 11, 2019 12:17:37 PM MST Bastiaan Veelo via Digitalmars- d-learn wrote: > Recently I got my first surprise with our use of D. The symptom > was that two local variables in two different functions appeared > to be sharing data. > > A simplified example is shown below (the

Re: Unexpected aliasing

2019-11-11 Thread Antonio Corbi via Digitalmars-d-learn
On Monday, 11 November 2019 at 19:17:37 UTC, Bastiaan Veelo wrote: Recently I got my first surprise with our use of D. The symptom was that two local variables in two different functions appeared to be sharing data. A simplified example is shown below (the original was machine translated

Unexpected aliasing

2019-11-11 Thread Bastiaan Veelo via Digitalmars-d-learn
Recently I got my first surprise with our use of D. The symptom was that two local variables in two different functions appeared to be sharing data. A simplified example is shown below (the original was machine translated from Pascal and involved templates and various levels of indirection).