This page is part of the web mail archives of SRFI 25 from before July 7th, 2015. The new archives for SRFI 25 contain all messages, not just those from before July 7th, 2015.
Jussi Piitulainen <jpiitula@xxxxxxxxxxxxxxxx> writes: > Radey Shouman writes: > > Nevertheless, using the array functions with vector arguments can be > > very convenient, could disjointness from vectors (and even strings) > > be left unspecified? > > Disjointness means that the implementation types do not leak through. > > If both (vector? arr) and (array? arr) yield #t, then (vector-ref arr > k) must do what (array-ref arr k) does, and so on. To implement that, > one should first have disjoint types, (r5rs-vector? o) and (array? o), > and then make (vector? o) be their sum (or (r5rs-vector? o) (array? > o)), and (vector-ref o k) would dispatch to one of (r5rs-vector-ref o > k) or (array-ref o k). That is not the situation that I had in mind. In SCM, for example, all vectors are arrays, but some arrays are not vectors, in particular, of course, multidimensional arrays are not vectors. So the two disjoint types are (R5RS) vectors, and, say, general-arrays. In this case, no change need be made to VECTOR-REF? or VECTOR, but ARRAY? must return true for vectors, and ARRAY-REF must behave as VECTOR-REF for vector arguments. Some calls to array-constructing functions return vectors, but array handling code can be written without knowing or caring whether an array happens to be a vector or not. I think this sort of flexibility is useful for implementors. The only cost is that disjointness cannot be guaranteed between arrays and vectors -- and I'm not sure why it is even particularly desireable. > On the other hand, (array? vec) might yield #f and (array-ref vec k) > could still do the right thing. Cough. Even (share-array vec proc) > could do the right thing. Oho. But strings seem harder - almost a > parallel implementation. And there would be runtime dispatch on > argument types all over the place. Certainly ARRAY-REF and SHARE-ARRAY must do the right thing iff their array argument is an array in the sense of ARRAY? . I suggest only that there is no need to require that (vector? x) return false for all x such that (array? x) returns true, not that you require any particular behavior when any vector or string is passed to an array procedure. > Ok, it seems workable if you like that sort of thing. Scheme has not > taken this route. There is no vector-append (I think). Perhaps there > could be another abstraction layer on top of strings, vectors and > arrays, one that would just pay for the dispatching? On the other hand, until R4RS there was no formal requirement that, for example, lists and vectors were disjoint. You seem to be arguing against a generic sequence type, which I do not propose.