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,dad94612ff745427 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Wed, 10 May 2006 14:07:18 -0500 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Instantiating private types with discriminants? References: <1147252198.138173.203910@j73g2000cwa.googlegroups.com> <44623869$0$4504$9b4e6d93@newsread2.arcor-online.net> Date: Wed, 10 May 2006 21:05:34 +0200 Message-ID: <87d5elk8e9.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:I4H8a/8TpCbfMnA/YsauXTvszyc= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.57.11 X-Trace: sv3-srDUJB7Z926CL60MEkUb8DINb77EGkHwa1aunoTGFqePsVoVJfV6d7PURoKVz+Zv4dPsir0UWT8Xs8j!YwebN3Vf7Mv9w60bbfV/MmwvScxNfL8jJhJm9LsOp0E4g6LMME/BWcvJhGXlCfOjVhpvkraa X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:4182 Date: 2006-05-10T21:05:34+02:00 List-Id: Here is a complete, working example, in case you're confused. It summarises everything we've said before: package (possibly, like here, nested in the procedure), freezing rules, abstract procedure in the base type, no access type, and declaring the object at the last moment. Now, can you answer this question: which subprograms in that example are primitive and which ones are not? -- Ludovic Brenta. with Ada.Float_Text_IO; with Ada.Integer_Text_IO; with Ada.Text_IO; procedure Dispatch is package P is type General_T is abstract tagged null record; function Get return General_T'Class; procedure Put (Item : in General_T) is abstract; type Type_A is new General_T with record Data : Integer; end record; procedure Put (Item : in Type_A); type Type_B is new General_T with record Data : Float; end record; procedure Put (Item : in Type_B); end P; package body P is function Get return General_T'Class is begin return Type_A'(Data => 10); end Get; procedure Put (Item : in Type_A) is begin Ada.Text_IO.Put ("A: "); Ada.Integer_Text_IO.Put (Item.Data); end Put; procedure Put (Item : in Type_B) is begin Ada.Text_IO.Put ("B: "); Ada.Float_Text_IO.Put (Item.Data); end Put; end P; use P; Var_A : General_T'Class := Get; begin Put (Var_A); end Dispatch;