Re: empty intervals

*Per Bothner*29 Jul 2015 23:36 UTCOn 07/29/2015 03:01 PM, Bradley Lucier wrote: >>> Perhaps if I understood the use of such things. We already have >>> scalars, why do we need zero-dimensional arrays? >> >> In APL languages, a scalar is the same as 0-rank array. In Scheme, >> I'd say a zero-dimensional array is the same as a box, in the SRFI-111 sense. > > Yes, I mis-spoke, I meant that we have boxes (or at least most schemes do). "Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary." Removing the restriction that dimensions > 0 means you can remove boxes as a separate concept. More generally, if you have a concept or operation defined for i, i > 0 - it usually turns out to be a good idea to also define the concept or operation for i=0. >>> Or arrays that >>> can’t return any values, because their underlying domains are empty? >> >> Why do we need vectors or lists or strings that can't return any values, >> because their underlying domains are empty? > > Strings, vectors, and lists all have a fixed “dimension” (of 1) and a fixed > lower bound (of 0), so the only other thing that needs specifying is the upper > bound. So it is perfectly reasonable to have only one empty vector, one empty >string, one empty list, all of which have an “upper bound” of zero. > > In our case there could be many “empty” arrays, and they could be empty for any number of reasons. I think you're conflating two different questions here: (1) Should we allow intervals with zero elements such as (interval #(0) #(0))? (2) Should an empty interval such as as (interval #(0) #(0)) be considered equal to another empty interval, such as (interval #(1) #(1))? I interpreted the your question as referring to (1), and that's what I responded to. You're now raising issue (2), which is separate though related. Note we can simplify much of the specification and API by restricting lower bounds to zeros. That doesn't remove essential functionality, and avoids (some of) the complication of different empty intervals. Though I think you still want to be able to distinguish between (interval #(10 0)) and (interval #(0 10)). Think of matrix/array concatenation. A concatenation along the 0'th dimension of #(20 10) and #(0 10) arrays should return the former, while concatenating #(20 10) and #(10 0) arrays should be an error. However, as long the specification supports non-zero lower bounds, then we have to distinguish (interval #(0) #(0)) and (interval #(1) #(1)). -- --Per Bothner xxxxxx@bothner.com http://per.bothner.com/