Skip to content

Document how to fix varray/darray warnings #779

Open
@fredemmott

Description

@fredemmott

As one example, unset($varray[$x]) raises a promotion-to-darray warning, and is generally a bad idea.

We should document:

  • vec\filter for the most common correct usage of this
  • vec\take, vec\drop for when the keys don't matter, filter is wrong
  • the question 'you have container[0 => 'a', 1 => 'b', 2 => 'c'] - for your use case, do you expect deleting key 1 to give you container[0 => 'a', 2 => 'c'], or container[0 => 'a', 1 => 'c']?
    • if keys 0 and 1, Vec\concat(Vec\take, Vec\drop) when for some reason (?) we actually do want to remove an item in the middle without using vec\filter
    • if keys 0 and 2:
      • reinforce that varray and darray are describing guesses at the correct type; if you need to preserve keys, it's likely that the guess is wrong, and the correct fix is to replace the varray type with a darray
      • replacing varray with a darray is a safe change at runtime: they're the same, except in which behaviors warn
  • if the keys are data - for example, timestamps, dates, IDs, etc:varray was wrong, darray is correct. varray is only for containers where keys 0..(count - 1) are acceptable. Treat as the 'keys 0 and 2' case above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions