From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: New aggregates with Ada 2022. Date: Wed, 29 Jun 2022 14:06:31 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net q847utBj+UB/5NsMeWM+9A1aF9NLR8dUMZU/F26dUNup1AY1/D Cancel-Lock: sha1:Iurg3WerxQJdma8s75nSsgoxWVE= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:64051 List-Id: On 2022-06-29 11:30, Jeffrey R.Carter wrote: > On 2022-06-29 06:01, Randy Brukardt wrote: >> >> But there is (or shouldn't be) anything special about a >> one-dimensional array (presuming you intend to allow arrays with >> more dimensions). And the "abstraction" you talk about is selecting >> a bunch of barely related elements from a multi-dimensional array. > > Arrays are usually used to implement map, (mathematical) matrices and > vectors, or sequences. Each usage tends to have unique features: > > * Maps are usually constrained. It does not make sense to concatenate, > sort, slice, or slide a map. In mathematics, maps (functions) are often sliced, in other words restricted to a subset of their full domain. They are also often concatenated, in the sense of combining functions defined on separate domain sets into a combined function defined on the union of those separate domain sets. Those operations would be useful in programs too. The essential aspect of maps and map operations is that there is no "sliding" that changes the relationship of domain values (keys) with range values. That said, it very often makes sense to provide sorted access to the elements of a map, sorted by some criterion, while maintaining the relationship of keys and their mapped values. That might be seen as sorting the map into a sequence (as described below). > * Matrices have component types that behave like numbers. The > mathematical definition of matrices includes integer indices with a > lower bound of 1. Vectors are usually considered to be matrices of one > column ("column vector") which can be transposed to obtain matrices of > one row ("row vector"). Computations that really use matrices (as opposed to multi-dimensional maps or plain arrays) very often make use of slices in the form of selected rows, columns, diagonals, or contiguous submatrices, with sliding of indices. > * Sequences are usually unconstrained. Typical discussion of sequences > outside of programming use integer values to indicate positions, using > terms such as the first thing in a sequence, the second thing, ..., so > indices should be of an integer type with a lower bound of 1. It > sometimes makes sense to concatenate, sort, slice, or slide sequences. Yes. But IME it is almost never useful /not/ to slide the indices. > A language that provided direct support for these abstractions should > not need to provide arrays. Except if someone invents new abstractions and needs a "raw memory" type to implement them. I like that Ada is a multi-level language, with both high-level services (eg. containers) and low-level services (arrays). As long as Ada uses arrays to represent sequences, such as character strings, array slices are quite nice to have, at least as values. I have not often needed to use a slice as a variable (eg. as the target of an assignment, or as an "out" parameter).