gonum / hdf5

hdf5 is a wrapper for the HDF5 library
BSD 3-Clause "New" or "Revised" License
131 stars 33 forks source link

hdf5: start handleing references #36

Open donkahlero opened 6 years ago

donkahlero commented 6 years ago

In earlier discussions, such as https://github.com/gonum/hdf5/pull/15, we talked about about working with an "HDF5 DataType that describes a pointer to x". As it is right now, whenever we are receiving a pointer, we are dereferencing it and are working with the underlying value.

The code that was at the center of the discussion was:

when creating a DataType

case reflect.Ptr:
     return NewDataTypeFromType(t.Elem())

and when performing encoding in our cmem package:

case reflect.Ptr:
    return enc.Encode(rv.Elem())

Looking at the HDF5 Documentation describing that topic, one notices that this is a bit more complex than we thought in our discussions. The guys there have a separate interface for handling the issue: Reference Interface.

Therefore, if we want to support those referencing types, we would need to create a wrapper for the named interface.

What still would not be resolved by adding the interface, is the issue of what happens if someone would try to e.g. append a pointer to a Go value without going through such an interface. Would we error? Or would we keep the status quo?