vector icon indicating copy to clipboard operation
vector copied to clipboard

Storable Vector constructor is not exported

Open phadej opened this issue 11 months ago • 3 comments

which fordbids doing some stuff.

The MVector constructor is exported, so I can workaround stuff for now, but it's still not great.

phadej avatar Feb 05 '25 12:02 phadej

I think that exposing constructors for mutable was a mistake. But is there anything that that isn't covered by unsafe{To,From}ForeignPtr{,0}?

Shimuuar avatar Feb 05 '25 13:02 Shimuuar

I think that exposing constructors for mutable was a mistake. But is there anything that that isn't covered by unsafe{To,From}ForeignPtr{,0}?

Probably not, but for primitive vectors there aren't conversions to/from ByteArrays, so I wasn't even looking for conversions to ForeignPtr.

I'd say if you going to hide storable MVector constructor (please don't), you should hide primitive MVector and Vector constructors; otherwise there is inconsistency in API.

phadej avatar Feb 05 '25 14:02 phadej

Probably not, but for primitive vectors there aren't conversions to/from ByteArrays, so I wasn't even looking for conversions to ForeignPtr.

That's clearly a missing API.

What I don't like about exposed constructors: their use is unsafe and they're imported by default, If one would say import some Unsafe module to get access to constructors it wouldn't be bad. But vector originally did a poor job at separating safe and unsafe API. And any attempt to reorganize would cause too much breakage.

Shimuuar avatar Feb 05 '25 14:02 Shimuuar