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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.217.9 with SMTP id p9mr107947itg.0.1473452653638; Fri, 09 Sep 2016 13:24:13 -0700 (PDT) X-Received: by 10.157.8.164 with SMTP id 33mr493352otf.2.1473452653605; Fri, 09 Sep 2016 13:24:13 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!i184no2234602itf.0!news-out.google.com!b4ni14246iti.0!nntp.google.com!i184no2234594itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 9 Sep 2016 13:24:12 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=75.161.71.70; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 75.161.71.70 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Are mutually dependant and possibly recursive types using Containers possible? From: Shark8 Injection-Date: Fri, 09 Sep 2016 20:24:13 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31740 Date: 2016-09-09T13:24:12-07:00 List-Id: Alright, let's say we're implementing a programming a programming language = -- because the problem becomes very apparent there -- and it has a simple = set of two primitive types, Real and Integer, and two complex ones, Array a= nd String. If it were just the primitive-types, we could use: Type Primitive(Is_Real : Boolean) is record case Is_Real is when True =3D> Real_Value : Float; when False =3D> Integer_Value : Integer; end case; end record; We could add Strings easily enough: Package String_Holder is new Ada.Containers.Indefinite_Holders( String ); =20 Type Type_Indicator is ( TI_Integer, TI_Real, TI_String ); =20 Type Item( Indicator : Type_Indicator ) is record case Indicator is when TI_Integer =3D> Integer_Value : Integer; when TI_Real =3D> Real_Value : Float; when TI_String =3D> String_Value : String_Holder.Holder; end case; end record; But with adding arrays things break down: we can't instantiate Ada.Containers.Indefinite_Vectors for use in Item beca= use Item isn't defined at that point, yet we absolutely need it in order to= make it (the structure/definition) simple. True, we could avoid this if arrays of arrays aren't required/allowed, but = the problem comes back if the language introduces/requires references and, = arguably, pointers. (The difference being that the empty-holder would not b= e allowed in a reference, but would in a pointer [whose null value would be= the no_element constant].)