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,3d3f20d31be1c33a X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Warts was Re: The stupidity of all the Ariane 5 analysts. Date: 1997/08/10 Message-ID: #1/1 X-Deja-AN: 263346259 References: <33C835A5.362A@flash.net> <33CC0548.4099@flash.net> <5qitoi$fdv$1@news.irisa.fr> <33CD6512.2404@flash.net> <01bc92e6$7a6f9e40$287b7b7a@tlo2> <33CEAF05.6389@flash.net> <33D2827B.41C67EA6@eiffel.com> <5qucs7$jie$3@flood.weeg.uiowa.edu> <33D3F2CB.61DC@flash.net> <5r4952$nca$1@flood.weeg.uiowa.edu> <33DE3CC7.2294@gsg.eds.com> <33E07E29.69CB@eurocontrol.fr> <33E7B7A5.56FF@gsg.eds.com> <5scqlr$ju@news.sei.cmu.edu> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-08-10T00:00:00+00:00 List-Id: In article , Brian Rogoff wrote: >generic >package AGL.Sets.Iterators is > type Iterator_Type is private; > > function Start ( Set : Set_Type ) return Iterator_Type; > function Finish ( Set : Set_Type ) return Iterator_Type; > > ... etc. ... > > -- ILLEGAL! These signatures can't be instantiated here!!! > > package Forward_Iterators is > new AGL.Forward_Iterators(Value_Type, Iterator_Type, Value_Ptr, > Next, Get_Value, Set_Value, Get_Pointer); > > package Bidirectional_Iterators is > new AGL.Bidirectional_Iterators(Value_Type,Iterator_Type,Value_Ptr, > Next,Prev,Get_Value,Set_Value, > Get_Pointer,"="); > >end AGL.Sets.Iterators; > >So what do we do about this problem? There are numerous workarounds... Here's one, though I haven't tried to compile it. This issue is that the full view of the type needs to have been defined prior to instantiation of the generics. generic package AGL.Sets.Iterators is package Iterator_Parents is type Iterator_Parent is private; private type Iterator_Parent is ...; end Iterator_Parents; type Iterator is new Iterator_Parents.Iterator_Parent; end; Won't this solve the problem? Yes, it seems that being able to interleave private and public sections would be a convenient feature, because you could do this: generic package AGL.Sets.Iterators is type Iterator is private; private type Iterator is ...; -- full view public end; but you can get almost that effect using nested packages. It's the same trick you do in Ada 83 to be able to derive from a type declared in the same package spec. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271