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=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,842accb6a7d76669 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-02 13:46:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Eric Merritt Newsgroups: comp.lang.ada Subject: Re: List container strawman 1.1 Date: Fri, 2 Nov 2001 13:45:29 -0800 (PST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: avanie.enst.fr 1004737573 43716 137.194.161.2 (2 Nov 2001 21:46:13 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 2 Nov 2001 21:46:13 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: In-Reply-To: <3BE301D1.4010106@telepath.com> Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:15705 Date: 2001-11-02T13:45:29-08:00 Not to rain on the discussion but I have to say that the use of the "+" instead of Constructor is not very intuitive. Someone suggested Make and Construct wouldn't be bad, but I think "+" lacks readability and could be confusing. --- Ted Dennison wrote: > I have a new version of the strawman up at my > website at > http://www.telepath.com/dennison/Ted/Containers-Lists-Unbounded.ads.html > > . This version has the cascading style sheet too, so > hopefully nearly > everyone should be able to read it. > > I tried to incorporate all of today's comments that > don't require > further discussion. If you made a comment that isn't > incorporated, it > either means that I think it need more discussion, > or I forgot (sorry, > it happens). If I missing something, please point it > out. > > I'm going to make one more attempt to attach it as > text and not HTML. It > may look a bit ugly due to some lines being longer > than 60 characters. > > > with Ada.Finalization; > with Ada.Streams; > > ------------------------------------------------------------------------------- > -- This file contains a proposal for a standard Ada > list package. > -- > -- version - Strawman 1.1 > ------------------------------------------------------------------------------- > generic > type Element is private; > package Containers.Lists.Unbounded is > > > ----------------------------------------------------------------------------- > -- The list type. I know the name's a bit > redundant, but it doesn't > look too > -- bad, and any fully-named use will have to > have a different name > for the > -- package anyway. > > ----------------------------------------------------------------------------- > type List is private; > > > ----------------------------------------------------------------------------- > -- List construction operations. The returned > list will contain > *copies* of > -- all the elements in the source lists, so > these routines could get > -- time-consuming. However, they should be > useful for Lisp-like > processing. > -- > -- I'm trying out using unary plus ("+") for the > "Construct" > routine, but > -- that's not a common idiom right now. > > ----------------------------------------------------------------------------- > function "&" (Left, Right : Element) return > List; > function "&" (Left : Element; Right : List) > return List; > function "&" (Left : List; Right : Element) > return List; > function "&" (Left, Right : List) return List; > function "+" (Initial_Element : Element) return > List; > > > ----------------------------------------------------------------------------- > -- "push" and "pop" operations. Pops on empty > lists raise No_Item. > > ----------------------------------------------------------------------------- > No_Item : exception; > > procedure Push_Front (Target : in out List; > New_Element : in > Element); > procedure Pop_Front (Target : in out List; > Old_Element : out > Element); > procedure Push_Back (Target : in out List; > New_Element : in > Element); > procedure Pop_Back (Target : in out List; > Old_Element : out > Element); > > > ----------------------------------------------------------------------------- > -- Non-modifying query operations. > > ----------------------------------------------------------------------------- > function Is_Empty (Subject : List) return > Boolean; > function Size (Subject : List) return > Natural; > function Front (Subject : List) return > Element; > function Back (Subject : List) return > Element; > > > ----------------------------------------------------------------------------- > -- Passive iterator. Operation will be applied > on each element on > the list > -- Opertion can terminate this process early by > setting Quit to True. > > ----------------------------------------------------------------------------- > generic > with procedure Operation (Target : in out > Element; Quit : out > Boolean); > procedure Passive_Iterator (Target : in out > List); > > > ----------------------------------------------------------------------------- > -- Iteration routines. For an empty list, First > = Done_Iterating. > Item and > -- Remove raise No_Item if they are called with > a value of > Done_Iterating. > -- As written, a typical iteration idiom would > look like: > -- > -- i := My_Lists.First (My_List); > -- while i /= My_Lists.Done_Iterating loop > -- do stuff with My_Lists.Item(i); > -- i := My_Lists.Next (i); > -- end loop; > -- > -- Another alternative using "Size" would be: > -- > -- i := My_Lists.First (My_List); > -- for iteration_count in 1..My_Lists.Size > (My_List) loop > -- do stuff with My_Lists.Item (i); > -- i := My_Lists.Next (i); > -- end loop; > -- > > ----------------------------------------------------------------------------- > type Iterator is private; > Done_Iterating : constant Iterator; > > function First (Subject : List) return > Iterator; > function Last (Subject : List) return > Iterator; > function Next (Location : Iterator) return > Iterator; > function Previous (Location : Iterator) return > Iterator; > function Item (Location : Iterator) return > Element; > > -- Ideally these routines would verify that > Location was issued for > the Subject > -- list and is still valid, but that would be > tough to enforce. > Better to call > -- such misuse a "bounded error", or somesuch. > > ----------------------------------------------------------------------------- > -- Remove the element at the given location, and > advance Location to > the next > -- element. > -- If Location=Done_Iterating then No_Item will > be raised. > -- If Location=First, then Location will be set > to the new First. > -- If Location=Last, then Location will be set > to Done_Iterating. > -- otherwise, Location will be set to what Next > was previously (the next > -- element after the removal). > > ----------------------------------------------------------------------------- > procedure Remove (Subject : in out List; > Location : in out Iterator); > > > ----------------------------------------------------------------------------- > -- Insert the given element at the given > location in the list (in > front of > === message truncated === __________________________________________________ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com