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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d650bb993a154b84,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!e10g2000prf.googlegroups.com!not-for-mail From: mhamel_98@yahoo.com Newsgroups: comp.lang.ada Subject: Learning tagged types Date: Fri, 22 Feb 2008 15:23:37 -0800 (PST) Organization: http://groups.google.com Message-ID: <31ec7e11-3cd0-4f3c-ad11-c06e7edfb9cb@e10g2000prf.googlegroups.com> NNTP-Posting-Host: 132.228.195.206 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1203722618 1541 127.0.0.1 (22 Feb 2008 23:23:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 22 Feb 2008 23:23:38 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e10g2000prf.googlegroups.com; posting-host=132.228.195.206; posting-account=5z8IJQkAAAAuH1CVqapXiEqPOXq8UfDM User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20002 Date: 2008-02-22T15:23:37-08:00 List-Id: Hello, this is a representative bit of code I use and, experimenting with tagged types, want to know if/how this can be cleanly moved to a more object oriented format. I think I want proc and def to be abstract procedures, that requires the "object" Proc_Def itself to be abstract, that means declaring new packages everytime I have a new Proc_Def? Thanks for any pointers (no pun intended), with Text_Io; with Ada.Containers.Doubly_Linked_Lists; procedure Tag_Test2 is type Proc_Def; type Proc_Ptr is access procedure (Def : Proc_Def; Val : Float); type Term_Ptr is access procedure (Def : Proc_Def); type Proc_Def is record Name : String (1 .. 4); Proc : Proc_Ptr; Term : Term_Ptr; end record; package DLL is new Ada.Containers.Doubly_Linked_Lists (Proc_Def); Proc_List : DLL.List; procedure Insert_Proc (Def : Proc_Def) is begin Proc_List.Append (Def); end Insert_Proc; function Retrieve_Proc return Proc_Def is begin return Proc_List.First_Element; end Retrieve_Proc; procedure Proc1 (Def : Proc_Def; Val : Float) is begin Text_Io.Put_Line (Def.Name & ": processing - " & Val'Img); end Proc1; procedure Term1 (Def : Proc_Def) is begin Text_Io.Put_Line (Def.Name & ": shutting down"); end Term1; Test_Proc : Proc_Def; begin Insert_Proc (("test", Proc1'access, Term1'access)); Test_Proc := Retrieve_Proc; Test_Proc.Proc (Test_Proc, 5.0); Test_Proc.Term (Test_Proc); end Tag_Test2;