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: a07f3367d7,10b4863a0a2cf267 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!15g2000yqi.googlegroups.com!not-for-mail From: Gautier write-only Newsgroups: comp.lang.ada Subject: Re: Type of the target of an assignment shall not be abstract Date: Tue, 16 Feb 2010 04:14:06 -0800 (PST) Organization: http://groups.google.com Message-ID: <5ed98506-27b6-4428-a773-a36de6edb1ed@15g2000yqi.googlegroups.com> References: <770863d9-14ae-4a05-b924-2dfeda7a96a8@f15g2000yqe.googlegroups.com> <39f56354-a2e2-4133-bbad-9343b2f22119@k6g2000prg.googlegroups.com> NNTP-Posting-Host: 206.122.158.4 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1266322446 8563 127.0.0.1 (16 Feb 2010 12:14:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 16 Feb 2010 12:14:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 15g2000yqi.googlegroups.com; posting-host=206.122.158.4; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9264 Date: 2010-02-16T04:14:06-08:00 List-Id: > Choosing between both tricks, I'd prefer Dmitry's. > I'll give a clear name to the concrete-before-abstract type, like > "Pre_Root", and try to have it private. > Let's see how it turns out... It turns out perfectly. *** Spec, private part: -- We have a concrete type as hidden ancestor of the Excel_Out_Stream root -- type. A variable of that type is initialized with default values and -- can help re-initialize a Excel_Out_Stream when re-used several times. -- See the Reset procedure in body. -- type Excel_Out_Pre_Root_Type is tagged record [the 14 components] end record; type Excel_Out_Stream is abstract new Excel_Out_Pre_Root_Type with null record; *** Body: procedure Reset( xl : in out Excel_Out_Stream'Class; format : Excel_type:= Default_Excel_type ) is dummy_xl_with_defaults: Excel_Out_Pre_Root_Type; begin ... dummy_xl_with_defaults.format:= format; Excel_Out_Pre_Root_Type(xl):= dummy_xl_with_defaults; end Reset; *** GNAT and ObjectAda are happy, I as well :-) Philosophically, it seems reasonable that an abstract type should be somewhat "limited" in its use (NB: I've put ""'s around the word 'limited' :-) ) ______________________________________________________________ Gautier's Ada programming -- http://gautiersblog.blogspot.com/