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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ea19776e3073a96 X-Google-Attributes: gid103376,public From: Geoff Bull Subject: Re: C/C++ programmer giving Ada95 a chance -- writing an emulator. Date: 2000/03/31 Message-ID: <38E44CC7.4206E027@acenet.com.au>#1/1 X-Deja-AN: 604681033 Content-Transfer-Encoding: 7bit References: <38E3DBD7.27F5B246@acenet.com.au> <2YSE4.251$sy6.25957@news.pacbell.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 954486100 203.35.118.1 (Fri, 31 Mar 2000 17:01:40 EST) Organization: Customer of Telstra Big Pond Direct MIME-Version: 1.0 NNTP-Posting-Date: Fri, 31 Mar 2000 17:01:40 EST Newsgroups: comp.lang.ada Date: 2000-03-31T00:00:00+00:00 List-Id: tmoran@bix.com wrote: > > > This_Delimiter := Delimiter(File_Name'Class(File_Name)); > > (he presumably meant to say: > > This_Delimiter := Delimiter(Heirarchical_File_Name_Type'Class(File_Name)); > > ) Another of the many minor mistakes in what is still an excellent book. > > The assignment to File_Name_Copy throws away > > the tag of File_Name, and the call on Delimiter always dispatches > > to the Heirarchical_File_Name_Type version of the function. That makes sense. If I Initialise the array like so: Op_Table : array (Opcode) of Op_Root := (0 => Op_Root (O0), others => OU); then make the assignments: Op_Table (1) := Op_Root (O1); Op_Table (2) := Op_Root (O2); Op_Table (3) := Op_Root (O3); I get the output: opcode 00 undefined opcode undefined opcode undefined opcode undefined opcode What is going on here? It look like the assigments throw away the tag (like Cohen says it should) but the initializer keeps the tag. Indeed the RM says in section 3.9 (22): "The tag of an object of a class-wide tagged type is that of its initialization expression. " The trouble is Op_Table components are not of a class wide type. Instead section 3.9 (20) applies: "The tag of a stand-alone object, a component, or an aggregate of a specific tagged type T identifies T" > I think we have here both an error in Gnat and an error in > Cohen's book! Unless somebody can show me where the RM says otherwise, I agree. I guess I'd better report this. Thanks for the enlightenment. Cheers Geoff