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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,be02bcdb8f46ddd5,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews1.google.com!not-for-mail From: jonas.nygren@telia.com (jn) Newsgroups: comp.lang.ada Subject: An improved Ada? Date: 27 Sep 2004 12:38:51 -0700 Organization: http://groups.google.com Message-ID: <311c6b78.0409271138.1795d07c@posting.google.com> NNTP-Posting-Host: 217.210.29.242 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1096313931 25285 127.0.0.1 (27 Sep 2004 19:38:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 27 Sep 2004 19:38:51 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4282 Date: 2004-09-27T12:38:51-07:00 List-Id: Hi, after spending numerous hours to do a simple double linked list package - yes, I have seen charles - a 5 hours tedious car drive came up with the following example of an improved Ada language: - prefix notation (as for tasks and protected types) - Ada OO syntax in line with tasks and protected objects - reference types - controlled, allocates from Storage_Pools.Garbage_Collected :) - implicit up- and down-conversions Here is my small example, based on the simset-library from Simula, not complete but it should be easy for you to fill out the rest:) package Simset is tagged type List_Type is private begin function First return Link_Type; end List_Type; tagged type Link_Type is private begin function Next return Link_Type; end Link_Type; private tagged type Linkage_Type is Suc, Pred : Linkage; begin function Next return Linkage_Type; procedure Into (List : List_Type); procedure Initialize; end Linkage_Type; tagged type List_Type is new Linkage_Type with begin null; end List_Type; tagged type Link_Type is new Linkage_Type with begin null; end Link_Type; end Simset; package body Simset is tagged body Linkage_Type is function Next return Linkage_Type is begin if not Suc in List_Type then return Suc; else return null; end Suc; procedure Initialize is begin Suc := This; Pred := This; end Initialize; end List_Type; tagged body List_Type is function First return Link_Type is begin return Next; end First; end List_Type; tagged body Link_Type is function Next return Link_Type is begin return Linkage_Type(This).Next; end Suc; procedure Into (List : List_Type) is begin -- Unlink; -- remove from whichever list This is in -- manipulate pointers to put This last into List end Into; end List_Type; end Simset; -- Simset example usage with Simset and use; with Book_Intrinsics rename as BI; procedure Example is tagged Book_Shelf is new List_Type; tagged Shopping_Cart is new List_Type; tagged Book_In_Shelf is new Link_Type with �uthor : BI.Author_Type; Title : BI.Title_Type; end Book_In_Shelf; function Contains_Ada_In_Title (Title : BI.Title_Type) return Boolean is begin ... end; -- not part of example Shelf : Book_Shelf := new Book_Shelf; Book, Buy : Book_In_Shelf; Cart : Shopping_Cart := new Shopping_Cart; begin -- populate Shelf with books, not part of example Book := Shelf.First, while Book /= null loop if Ada_In_Title (Book.Title) then Buy := Book; Book := Book.Next Buy.Into (Cart); else Book := Book.Next; end if; end loop; -- pay for books in cart end Example;