Re: bool passed by ref, safe or not ?

2024-06-06 Thread Quirin Schroll via Digitalmars-d-learn
On Wednesday, 5 June 2024 at 18:31:12 UTC, Basile B. wrote: On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote: On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote: ```d void main(string[] args) { ushort a = 0b; bool* b = cast(bool*)&a; setIt(*b);

Re: How to pass in reference a fixed array in parameter

2024-06-06 Thread Quirin Schroll via Digitalmars-d-learn
On Tuesday, 4 June 2024 at 12:22:23 UTC, Eric P626 wrote: I am currently trying to learn how to program in D. I thought that I could start by trying some maze generation algorithms. I have a maze stored as 2D array of structure defined as follow which keep tracks of wall positions: ~~~ struct

Unintentional sharing?

2024-06-06 Thread Andy Valencia via Digitalmars-d-learn
I was using instance initialization which allocated a new object. My intention was this initialization would happen per-instance, but all instances appear to share the same sub-object? That is, f1.b and f2.b appear to point to a single object? Obviously I moved the new into the initializer c

Re: Unintentional sharing?

2024-06-06 Thread evilrat via Digitalmars-d-learn
On Thursday, 6 June 2024 at 17:49:39 UTC, Andy Valencia wrote: I was using instance initialization which allocated a new object. My intention was this initialization would happen per-instance, but all instances appear to share the same sub-object? That is, f1.b and f2.b appear to point to a s

Re: Unintentional sharing?

2024-06-06 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 6 June 2024 at 17:49:39 UTC, Andy Valencia wrote: I was using instance initialization which allocated a new object. My intention was this initialization would happen per-instance, but all instances appear to share the same sub-object? That is, f1.b and f2.b appear to point to a s

Re: Unintentional sharing?

2024-06-06 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 06, 2024 at 05:49:39PM +, Andy Valencia via Digitalmars-d-learn wrote: > I was using instance initialization which allocated a new object. My > intention was this initialization would happen per-instance, but all > instances appear to share the same sub-object? That is, f1.b and