Re: Pointer vs Ref

2025-07-04 Thread confuzzled via Digitalmars-d-learn
On 6/15/25 9:06 AM, Steven Schveighoffer wrote: On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. A ref cannot be a member of a type. But ref can be returned by

Re: Pointer vs Ref

2025-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. ```d // Represents our Backtester engine struct Engine { // It STORES a pointer to its data source. This is

Re: Pointer vs Ref

2025-06-11 Thread confuzzled via Digitalmars-d-learn
On 6/9/25 11:16 PM, monkyyy wrote: On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. The hard part is the `foreach` the simple answer is throw a ref before `v

Re: Pointer vs Ref

2025-06-11 Thread confuzzled via Digitalmars-d-learn
On 6/10/25 2:17 AM, Ali Çehreli wrote: On 6/9/25 12:24 AM, confuzzled wrote: > Is it possible to accomplish the following using ref instead of > pointers? Your example is a good case for a pointer. Was there a reason why a reference should be used? Just exploring the realm of possibilities

Re: Pointer vs Ref

2025-06-09 Thread Ali Çehreli via Digitalmars-d-learn
On 6/9/25 12:24 AM, confuzzled wrote: > Is it possible to accomplish the following using ref instead of > pointers? Your example is a good case for a pointer. Was there a reason why a reference should be used? Having said that, you can even drop the pointer and use a DataSource as-is: struct

Re: Pointer vs Ref

2025-06-09 Thread monkyyy via Digitalmars-d-learn
On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. import std.stdio; // Represents our large, external data source (like TimeSeries) struct DataSource { int[3

Pointer vs Ref

2025-06-09 Thread confuzzled via Digitalmars-d-learn
Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. import std.stdio; // Represents our large, external data source (like TimeSeries) struct DataSource { int[3] data; } // Represents our Backtester engine struct Engin