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,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-01 13:40:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!skynet.be!skynet.be!freenix!enst.fr!not-for-mail From: "Robert C. Leif" Newsgroups: comp.lang.ada Subject: RE: Ideas for Ada 200X Date: Sun, 1 Jun 2003 13:39:51 -0700 Organization: ENST, France Message-ID: NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: avanie.enst.fr 1054500026 98554 137.194.161.2 (1 Jun 2003 20:40:26 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sun, 1 Jun 2003 20:40:26 +0000 (UTC) To: , "Comp. Lang. Ada" Return-Path: X-Envelope-From: rleif@rleif.com X-Mailer: Microsoft Outlook, Build 11.0.4920 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Thread-Index: AcMoODFH7eeh3v/dQ/+Z2FkJUWfC6wAApT8Q X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:38291 Date: 2003-06-01T13:39:51-07:00 Below is a fragment of source for what I hope is an improvement on = bounded strings. It is to be extensible and have the functionality of XML = strings. Three different packages are needed to cover 8, 16, and 32 bit = characters, because common parents do not exist for Ada characters, strings, and = bounded strings. I had a similar structure in R. C. Leif and S. B. Leif, "Ada in Embedded Boards for Scientific and Medical Instruments", Proceedings, ACM SIGAda Annual International Conference (SIGAda '98), S. Carlson, Proceedings = Chair, M. Feldman, Program Chair, pp. 114-120, 1998. Bob Leif=20 ------------------------------------------------------------------ with Ada.Strings.Wide_Bounded; --For 8 bits similar with=20 --Ada.Strings.Bounded; with Pattern16_Pkg; with Ada.Strings; with Character_Sets16; with Strings8_16_32_Pkg; with Ada.Characters; with Ada.Characters.Wide_Latin_1; generic Max_Bd_Length : Positive; =20 Min_Bd_Length : Positive :=3D 1; =20 Character16_Set : Character_Sets16.Character16_Set_Type :=3D Character_Sets16.Latin_1_16_Char_Set; =20 Pattern : Pattern16_Pkg.Pattern_Bd16_Type :=3D Pattern16_Pkg.Null_Pattern_Bd16; type Generic_Bd16_W_Char_Set_Type is tagged private; private type Generic_Bd16_W_Char_Set_Type is tagged record Generic_Bd16_Part : Generic_Bd16_Type :=3D Null_Generic_Bd; Character16_Set_Part : Character16_Set_Type :=3D Character16_Set; Min_Bd_Length_Part : Positive :=3D Min_Bd_Length; Pattern_Part : Pattern_Bd16_Type :=3D Null_Pattern_Bd16; --This permits the Character16_Set to be specified at = instantiation --and defaults to Latin_1. end record; ------------------------------------------------------------------- "The Generic_Port package contains Port_Representation_Type, which is = tagged private. This record after instantiation and the subsequent addition of = the actual layout of the register, creates a record which describes the port = and the data it inputs or outputs." type Port_Representation_Type is tagged record Port_Part: Port_Type :=3D Port_Value; Register_Address_Part : Register_Address_Type :=3D Register_Address; Data_Direction_Part : Data_Direction_Type :=3D Data_Direction; Port_Object_Name_Part : Port_Object_Name_Type :=3D Port_Object_Name; end record; Since Port_Type, Port_Value, Register_Address_Type, Register_Address, Data_Direction_Type Data_Direction, and Port_Object_Name are all = generic, all types of computer ports can be modeled and manipulated by the subprograms contained in the generic. The actual modeling of the port content occurs after the instantiation. The use of generic type, permits the Port_Value to be 8, 16, 32, etc. bits wide. Similarly, the Register_Address can be a memory or port location. The procedure Write_Port_Representation stores the contents of the tagged record in the Log_File; and the procedure Create_Port is employed when the = second port of the same type needs to be created. -------------------------------------------------------------------------= - -----Original Message----- From: Dmitry A. Kazakov [mailto:mailbox@dmitry-kazakov.de]=20 Sent: Sunday, June 01, 2003 2:19 AM To: comp.lang.ada@ada.eu.org Robert C. Leif wrote: > Why not make a combination consisting of a tagged type inside of a > generic? Most of the types and objects of the tagged type are generic. > These Metaclasses are a good model of the real world. What do you mean? Unlike C++, Ada has no generic types. The problem is whether the [generic] library has to be based on static = vs.=20 dynamic polymorphism. A. Static polymorphism stands for generics (sometimes also for = overloading). A generic subroutine is polymorphic in the sense that its body is=20 parametrized by the formal parameters. B. Dynamic polymorphism stands for tagged types (also discriminated = types).=20 A dispatching subroutine is polymorphic because it may have different=20 bodies (for different types) Thus you have to choose either A or B. Both approaches have advantages = and=20 disadvantages. Theoretically B contains A, but practically it is either=20 impossible or less effective than A in many *very* important cases.=20 Therefore one should clearly inderstand the consequences of any decision = made. Especially because neither A nor B have not yet finished their=20 evolution in Ada (and other languages). So any wrong decision for a such important thing as the library which = will=20 be used practically everywhere, might freeze present, rather = unfortunate,=20 state of OO in Ada (in other languages it is not better). --=20 Regards, Dmitry A. Kazakov www.dmitry-kazakov.de