Access behaviour for Explorer.DataFrame

The Explorer team has decided that it makes more sense to raise (catching errors early) than return nil. How much this is violation of the Access behaviour is a good question. Here is what we can say:

  1. Keyword lists are used to model optional keys, but they raise if the key is not an atom
  2. Maps always return nil for missing keys, but they also have a convenience API for being strict, such as map.foo
  3. Nx tensors raise if you use access with an invalid dimension

I’d have to put more thought into it but, in the face of the two conflicting positions below, I’d probably stick with the first one:

  • We should let data structures decide what is best for them
  • Access should impose it to return nil

The Access behaviour requires you only to implement fetch and get_and_update, the other functionality is made available through the Access module itself. It is similar to a GenServer, where you implement handle_call but you must invoke GenServer.call.

We should add an API for it.