Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 22 June 2023 at 01:44:22 UTC, Jonathan M Davis wrote: On Wednesday, June 21, 2023 7:05:28 PM MDT Paul Backus via Digitalmars-d-learn wrote: [...] To add to that, it _has_ to know the element type, because aside from anything related to a type's size, it bit-blits the type's

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 22 June 2023 at 01:05:28 UTC, Paul Backus wrote: On Thursday, 22 June 2023 at 00:10:19 UTC, Cecil Ward wrote: Is .reserve()’s argument scaled by the entry size after it is supplied, that is it is quoted in elements or is it in bytes? I’m not sure whether the runtime has a

Re: A couple of questions about arrays and slices

2023-06-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 21, 2023 7:05:28 PM MDT Paul Backus via Digitalmars-d-learn wrote: > On Thursday, 22 June 2023 at 00:10:19 UTC, Cecil Ward wrote: > > Is .reserve()’s argument scaled by the entry size after it is > > supplied, that is it is quoted in elements or is it in bytes? > > I’m not sure

Re: A couple of questions about arrays and slices

2023-06-21 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 22 June 2023 at 00:10:19 UTC, Cecil Ward wrote: Is .reserve()’s argument scaled by the entry size after it is supplied, that is it is quoted in elements or is it in bytes? I’m not sure whether the runtime has a knowledge of the element type so maybe it doesn’t know anything about

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 21 June 2023 at 15:48:56 UTC, H. S. Teoh wrote: On Wed, Jun 21, 2023 at 02:09:26AM +, Cecil Ward via Digitalmars-d-learn wrote: First is an easy one: 1.) I have a large array and a sub-slice which I want to set up to be pointing into a sub-range of it. What do I write if I

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 21 June 2023 at 04:52:06 UTC, Jonathan M Davis wrote: On Tuesday, June 20, 2023 8:09:26 PM MDT Cecil Ward via Digitalmars-d-learn wrote: [...] When slicing, the end index is exclusive. e.g. [...] Actually concerning the garbage, I was rather hoping that it _would_ be garbage

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 21 June 2023 at 04:52:06 UTC, Jonathan M Davis wrote: On Tuesday, June 20, 2023 8:09:26 PM MDT Cecil Ward via Digitalmars-d-learn wrote: [...] When slicing, the end index is exclusive. e.g. [...] Thankyou to both posters for your exceptionally helpful and generous replies,

Re: is ref inout redundant in: ref inout(T) opIndex(size_t index)

2023-06-21 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 19 June 2023 at 18:19:18 UTC, mw wrote: 2) `inout T` alone Steve covered everything, though you might also like to read the inout spec: https://dlang.org/spec/const3.html#inout

Re: A couple of questions about arrays and slices

2023-06-21 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 21, 2023 at 02:09:26AM +, Cecil Ward via Digitalmars-d-learn wrote: > First is an easy one: > > 1.) I have a large array and a sub-slice which I want to set up to be > pointing into a sub-range of it. What do I write if I know the start > and end indices ? Concerned about an