Am Sa., 27. Feb. 2021 um 19:11 Uhr schrieb Adam Nelson <xxxxxx@nels.onl>:

I don't know about other SRFIs, but my intention in saying that flexvectors are disjoint from other types was to say that flexvectors are disjoint from other core Scheme/SRFI types. Not from any other unique types your Scheme implementation may define. Maybe it should be phrased differently.

Saying that "flexvectors" are disjoint from the core Scheme types makes sense, but saying that they are disjoint from all SRFI types, especially future ones, doesn't make sense. Types in Scheme are defined through predicates so you would have to be able to list all predicates that are supposed to be disjoint. (Here, two predicates `a?` and `b?` are called disjoint if no object fulfills both `a?` and `b?`.)

Reusing ring-buffer seems equivalent to how Gauche already handles SRFI 146 Mappings (they're just an alias for Gauche's tree-map type). SRFI 146 doesn't specifically say mappings are disjoint from other types, but it does say that "Mappings form a new type as if created by define-record-type." As far as I know, that's the same as saying they're disjoint from all other types.

This was my try at that time to make the disjointness requirement meaningful. However, it is not that helpful than I thought. The best possible it implies is that through the loading of (srfi 146), the mapping type is created (as if) through evaluating define-record-type. However, it doesn't and cannot prohibit that other SRFIs or further libraries depend on SRFI 146 and reexport SRFI 146's types. In a Scheme system that loads each library only once (essentially a requirement for practical matters), the type created through evaluating define-record-type can therefore be shared by several libraries.

As for conflating vectors and flexvectors, that's intentionally disallowed. The R7RS says that a vector's length is "fixed when the vector is created". If an object `x` can exist such that `(vector? x)` is true, but `(vector-length x)` can change, then that's a violation of the spec.

This is a good point and a very interesting one. It's a good reason why this SRFI should make "flexvectors" disjoint from vectors.

If we read the quote from the R7RS as an absolute requirement, every Scheme shipping a debugging library that not only allows inspecting but also modifying values wouldn't be a faithful implementation of the R7RS.

Marc

On 2/27/21 1:42 AM, Shiro Kawai wrote:
In the entry flexvector? it says 'disjoint' type predicate.  How much should it be disjoint from other datatypes?

This occurs to me when I'm implementing it in Gauche.  We already have a ring-buffer object, using flat storage and extending capability, and I can just use it as a flexvector by just adding procedures, without defining a new datatype.

Ring-buffer isn't in any srfi so far, so there's no problem to do so NOW.  But what if we have a ring-buffer srfi in future and it also want to have a disjoint type predicate?  In general, every time we add a new datatype to srfi and it says disjoint, how much should it cover?  Types in RnRS?  All previous srfis?

An implementation may choose to conflate vectors and flexvectors (doing so make interaction of multiple threads complex, as was discussed earlier, but it's a choice of the implementation.)   The current srfi has an example (flexvector? (vector 1 2 3)) => #f.  Should it be so?