Re: Array Indexing/Slicing Range Checking, Exceptions and @nogc

2016-03-30 Thread ag0aep6g via Digitalmars-d-learn
On 30.03.2016 15:44, Nordlöw wrote: On Wednesday, 30 March 2016 at 13:24:20 UTC, ag0aep6g wrote: [...] This is off topic, but don't mark templates like that @trusted. By doing so you also trust R, but you don't know if it's memory safe. Should I post in group "General" instead? No, no, I me

Re: Array Indexing/Slicing Range Checking, Exceptions and @nogc

2016-03-30 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 13:38:40 UTC, Adam D. Ruppe wrote: Don't use your ptr method. Instead, make it a slice method: `return _store[0 .. _length];` Now you can just index it internally and let the compiler automatically insert range checks. When you need the pointer, you still have s

Re: Array Indexing/Slicing Range Checking, Exceptions and @nogc

2016-03-30 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 13:24:20 UTC, ag0aep6g wrote: On 30.03.2016 15:12, Nordlöw wrote: https://github.com/nordlow/justd/blob/master/packedarray.d From there: this(R)(R values, bool assumeSortedParameter = false) @trusted nothrow @("complexity", "O(n*log(n))") if (isInp

Re: Array Indexing/Slicing Range Checking, Exceptions and @nogc

2016-03-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 13:12:49 UTC, Nordlöw wrote: I'm however uncertain about how to implement error handling of bounds checking and how these interact with `@nogc`. My main goal is to match semantics of builtin D arrays and slices. I would actually cheat on this somehow and actu

Re: Array Indexing/Slicing Range Checking, Exceptions and @nogc

2016-03-30 Thread ag0aep6g via Digitalmars-d-learn
On 30.03.2016 15:12, Nordlöw wrote: https://github.com/nordlow/justd/blob/master/packedarray.d From there: this(R)(R values, bool assumeSortedParameter = false) @trusted nothrow @("complexity", "O(n*log(n))") if (isInputRange!R) This is off topic, but don't mark templates like

Array Indexing/Slicing Range Checking, Exceptions and @nogc

2016-03-30 Thread Nordlöw via Digitalmars-d-learn
I'm working on a support-it-all Array implementation (with optional sortedness) at https://github.com/nordlow/justd/blob/master/packedarray.d that has a very flexible memory allocation model via either GC.malloc or via privately imported malloc, realloc and free. This in order to provide pure