Re: Confusion over what types have value vs reference semantics

2016-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 13, 2016 15:27:07 Neurone via Digitalmars-d-learn wrote: > On Sunday, 11 September 2016 at 16:14:59 UTC, Mike Parker wrote: > > On Sunday, 11 September 2016 at 16:10:04 UTC, Mike Parker wrote: > >> And here, no memory is allocated. barSlice.ptr is the same as > >> bar.ptr and

Re: Confusion over what types have value vs reference semantics

2016-09-13 Thread Neurone via Digitalmars-d-learn
On Sunday, 11 September 2016 at 16:14:59 UTC, Mike Parker wrote: On Sunday, 11 September 2016 at 16:10:04 UTC, Mike Parker wrote: And here, no memory is allocated. barSlice.ptr is the same as bar.ptr and barSlice.length is the same as bar.length. However, if you append a new element:

Re: Confusion over what types have value vs reference semantics

2016-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2016 at 16:10:04 UTC, Mike Parker wrote: And here, no memory is allocated. barSlice.ptr is the same as bar.ptr and barSlice.length is the same as bar.length. However, if you append a new element: barSlice ~= 10; The GC will allocate memory for a new array and

Re: Confusion over what types have value vs reference semantics

2016-09-11 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 11 September 2016 at 15:15:09 UTC, Neurone wrote: Hi, Are there universal rules that I can apply to determine what types have reference or value semantics? I know that for the basic primitive C types (int, bool, etc) has value semantics. Primitive types (int, bool, etc) and

Re: Confusion over what types have value vs reference semantics

2016-09-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/09/2016 3:15 AM, Neurone wrote: Hi, Are there universal rules that I can apply to determine what types have reference or value semantics? I know that for the basic primitive C types (int, bool, etc) has value semantics. In particular, I'm still trying to understand stack vs GC-managed

Confusion over what types have value vs reference semantics

2016-09-11 Thread Neurone via Digitalmars-d-learn
Hi, Are there universal rules that I can apply to determine what types have reference or value semantics? I know that for the basic primitive C types (int, bool, etc) has value semantics. In particular, I'm still trying to understand stack vs GC-managed arrays, and slices. Finally, I