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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,10b4863a0a2cf267 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!bolzen.all.de!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Type of the target of an assignment shall not be abstract Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <770863d9-14ae-4a05-b924-2dfeda7a96a8@f15g2000yqe.googlegroups.com> Date: Sun, 14 Feb 2010 18:57:48 +0100 Message-ID: NNTP-Posting-Date: 14 Feb 2010 18:57:40 CET NNTP-Posting-Host: eb910866.newsspool4.arcor-online.net X-Trace: DXC=nJSNimNGL`2lIh70@[ On Sun, 14 Feb 2010 06:20:32 -0800 (PST), Gautier write-only wrote: > A question for the RM hermeneutists. > The instruction marked below with ">>>" goes well through one Ada 95 > compiler (GNAT with -gnat95) but is not accepted by another one > (ObjectAda 7.2.2). > Which compiler is right ? > > procedure Init( > xl : in out Excel_Out_Stream'Class; > format : Excel_type:= Default_Excel_type > ) > is > dummy_xl_with_defaults: Excel_Out_File; > begin > -- Check if we are trying to re-use a half-finished object > (ouch!): > if xl.is_created and not xl.is_closed then > raise Excel_Stream_Not_Closed; > end if; > dummy_xl_with_defaults.format:= format; >>>> Excel_Out_Stream(xl):= Excel_Out_Stream(dummy_xl_with_defaults); > end Init; > >>>> excel_out.adb: Error: line 595 col 5 LRM:3.9.3(8), The type of the target of an assignment shall not be abstract > > For those asking themselves what the *@#$! that code is doing, since > the xl variable is already initialized, the purpose of the := is to re- > initialize an object (xl) with the default values of the root type. > Since the root type is abstract, I need a concrete derived object > (dummy_xl_with_defaults) to get these default values. Subsidiary > question: is there another way of doing that in one ':=' ? package P is type T is abstract tagged private; procedure Reset (X : in out T'Class); private type Root is tagged record -- Non-abstract I : Integer; end record; type T is abstract new Root with null record; end P; package body P is Defaults : Root := (I => 123); procedure Reset (X : in out T'Class) is begin Root (X) := Defaults; end Reset; end P;. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de