Deque impl.
monarch_dodra
monarchdodra at gmail.com
Tue Jan 29 22:55:53 PST 2013
On Tuesday, 29 January 2013 at 22:44:35 UTC, Robert Schadek wrote:
> On 01/29/2013 09:20 PM, monarch_dodra wrote:
>> 3. Nitpick: Don't use parenthesis for single arg templates:
>> No: "Deque!(int)"
>> yes: "Deque!int"
> May I ask why? Both are correct after all. Or is it just the
> preferred style?
It's just style, and a nitpick. Feel free to ignore it.
>> 5. Users expect "opSlice()" to produce an actual range. You
>> are using it to deep copy the deck. This goes against your
>> comment in regards to slicing an iterator. Just have your
>> "opSlice()" do the same as what "range()" does, and get rid of
>> "range()". This is the usage I'd expect:
>>
>> //----
>> Deque!int de = ... ;
>> Iterator!int it = de[];
>> writeln(it);
>> //----
> I submitted a bug report for sort recently (9091 became 8368).
> monarchdodra said (and pointed to source) that opSlice should
> return the same type in respect to the called object.
Yes, 9071. I remember it quite well, and it was the first thing
that came to mind the instant I saw your your code.
What I said is that for a *range* to offer correct *hasSlicing*
primitive, then the "opSlice(size_t, size_t)" primitive must
return the same type.
Deque is not a range though, Iterator is, and we're talking about
the primitive "opSlice()"
Again: this is a Container vs Range issue.
For example, built-in arrays also have this scheme.
//----
//statarr is a static array. A container. statarr is NOT a range.
int[5] statarr = [0, 1, 2, 3, 4];
//dynarrX are ranges extracted from their container
int[] dynarr1 = statarr[];
int[] dynarr2 = statarr[1 .. 3];
//----
As you can see, "int[]" != "int[5]"
More information about the Digitalmars-d
mailing list