On 18/04/2015 18:10, Nick Wellnhofer wrote:
Regarding Excise: I think VArray is missing a "splice"-like method. We could
either augment Excise to make it work like splice in Perl, or add an extra
method to insert elements at a certain location (maybe two methods for
inserting single elements and other VArrays).

Thinking more about this, I'd suggest to remove Shift and Unshift and add the following new methods:

    // Instead of Shift. Removes element at `tick` and moves the
    // following elements over. Shift(a) becomes Excise(a, 0).
    incremented nullable Obj*
    Excise(VArray *self, uint32_t tick);

    // Formerly known as Excise.
    void
    Excise_Range(VArray *self, uint32_t offset, uint32_t length);

    // Instead of Unshift. Inserts `elem` at `tick` moving the
    // following elements. Unshift(a, e) becomes Insert(a, 0, e).
    void
    Insert(VArray *self, uint32_t tick, decremented Obj *elem = NULL);

    // New method.  Inserts `other` array at `tick` moving the
    // following elements.
    void
    Insert_VArray(VArray *self, uint32_t tick, VArray *other);

Looks nice and orthogonal to me. shift/unshift is also a Perlism that isn't very intuitive IMO.

Nick

Reply via email to