From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: grassroots thoughts on access types Date: Sat, 10 Feb 2018 14:02:24 +0000 Organization: A noiseless patient Spider Message-ID: References: <5d9134c9-a7d4-468e-8685-ebbb393eabea@googlegroups.com> <13f51bd1-00ef-4d2a-94b9-2d2560b449f3@googlegroups.com> <7781f82a-7df3-4f00-9bc8-ee60c24311f6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="3f0772393081e6fad0b3e0b589a62a8b"; logging-data="5873"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EKEdjQqeLoPknGVM2fOE0s9Do4Q1cKJ0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:p8UKbN1/AK3GGgBaJ9dp3dab4I4= sha1:5CroZ4DBwtqsFidefWK4MmQa+OY= Xref: reader02.eternal-september.org comp.lang.ada:50367 Date: 2018-02-10T14:02:24+00:00 List-Id: Mehdi Saada <00120260a@gmail.com> writes: > while we're at it, how would I write in SPARK > type Cell is > record > Next: access Cell; > Value: Integer; > end record; You might implement the container as an array, and the Next field would be an index into the array (or some 'end of list' marker). type Base is range 0 .. N; subtype Index is Base range 1 .. Base'Last; End_Of_List : constant Base := 0; type Cell is record Next : Base := End_Of_List; Value : Integer; end record; type List is record Head : Base := End_Of_List; Contents : array (Index) of Cell; end record;