Re: trying to understand in, inout, and ref...

2020-01-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/22/20 10:33 AM, Adam D. Ruppe wrote: BUT if you change the length of it or reallocate it in any way those changes are NOT seen outside. So with AAs and slices, if you just want to work with existing elements, no need for ref. But if you are going to do any kind of resizing - adding or

Re: trying to understand in, inout, and ref...

2020-01-22 Thread mark via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 15:33:44 UTC, Adam D. Ruppe wrote: On Wednesday, 22 January 2020 at 15:26:06 UTC, mark wrote: I've done this but my impression from the docs is that passing slices and associative arrays is already done by reference so these aren't needed? They are pointers pa

Re: trying to understand in, inout, and ref...

2020-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 15:26:06 UTC, mark wrote: I've done this but my impression from the docs is that passing slices and associative arrays is already done by reference so these aren't needed? They are pointers passed by value. If you're familiar with C, think of passing struct A

Re: trying to understand in, inout, and ref...

2020-01-22 Thread mark via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 14:23:53 UTC, Paul Backus wrote: On Wednesday, 22 January 2020 at 10:49:07 UTC, mark wrote: Regarding generate(): allWords should never be changed (generate is called in a loop with the same allWords every time) -- so should it be `in WordSet allWords`? For pa

Re: trying to understand in, inout, and ref...

2020-01-22 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 10:49:07 UTC, mark wrote: Regarding generate(): allWords should never be changed (generate is called in a loop with the same allWords every time) -- so should it be `in WordSet allWords`? For parameters that shouldn't be changed, use const. So it should be `co