Re: "Flexvector" vs adding "capacity" to "vector"
Marc Nieper-WiÃkirchen 12 Oct 2020 14:47 UTC
Am Mo., 12. Okt. 2020 um 16:39 Uhr schrieb Erik Dominikus
<xxxxxx@gmail.com>:
>
> Dear SRFI-214 subscribers,
Thanks for sharing your thoughts with us.
> Its advantages compared to flexvectors:
>
> - It subsumes Scheme vectors, so it is backward-compatible with
> existing Scheme code: just set siz = cap = the length of the vector.
> - It does not define a new type, so it does not raise difficult
> questions about subtyping, nomenclature, name-prefixing,
> comparison/ordering, etc.
These are huge advantages.
> Its disadvantages compared to flexvectors:
>
> - It requires changing the layer below Scheme, although the change
> should be small if the underlying layer does not assume that vector
> contents cannot move.
> - Perhaps not everyone can afford that change.
This can be an obstacle for many Schemes. When you have an ordinary
non-resizable vector, a vector can be a (tagged) pointer to a struct
with a flexible array member roughly of the form
struct
{
size_t len;
object [];
};
In your approach, there is one more pointer indirection, making all
vector code slower.