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.66.243.5 with SMTP id wu5mr4033624pac.29.1429278175452; Fri, 17 Apr 2015 06:42:55 -0700 (PDT) X-Received: by 10.182.22.134 with SMTP id d6mr21296obf.41.1429278175413; Fri, 17 Apr 2015 06:42:55 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!l13no6337107iga.0!news-out.google.com!db6ni18153igc.0!nntp.google.com!m20no4084153iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 17 Apr 2015 06:42:55 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=67.0.18.148; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 67.0.18.148 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8def4a86-5835-4368-b414-63e12f1074e8@googlegroups.com> Subject: Interesting containers problem. From: Shark8 Injection-Date: Fri, 17 Apr 2015 13:42:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:25535 Date: 2015-04-17T06:42:55-07:00 List-Id: Ok, so let's say we have a type for Identifiers: SubType Identifier is String with Dynamic_Predicate =3D> Is_Valid( Identifier ) or else raise Parse_Error with "Invalid identifier: """ & Identifier &= '"'; --... -- ACH is a rename for Ada.Characters.Handling. Function Is_Valid( Input: String ) return Boolean is ( Input'Length in Positive and then ACH.Is_Letter(Input(Input'First)) and then ACH.Is_Alphanumeric(Input(Input'Last)) and then (for all Ch of Input =3D> Ch =3D '_' or ACH.Is_Alphanumeric(Ch)) and= then (for all Index in Input'First..Positive'Pred(Input'Last) =3D> (if Input(Index) =3D '_' then Input(Index+1) /=3D '_') ) ); And a few types for types: Type Data_Type is ( Integer, Float, Fixed ); Type Variable_Data( Type_Value : Data_Type ) is case Type_Value is when Integer =3D> Integer_Value : Standard.Integer; when Float =3D> Float_Value : Standard.Float; when Fixed =3D> Fixed_Value : Fixed_Type; -- Defined elsewhere. end case; end record; Now we can define a Symbol-table using the standard containers simply with = this: Package Symbol_Table is new Ada.Containers.Indefinite_Ordered_Maps( Key_Type =3D> Identifier, Element_Type =3D> Variable_Data, "<" =3D> Ada.Strings.Less_Case_Insensitive, "=3D" =3D> "=3D" ); And that's all well and good; however, there is one limitation here that is= revealed when you need nesting scopes -- there is, apparently, no way to d= efine an Element_Type to feed to Indefinite_Ordered_Maps which is an instan= ce of Indefinite_Ordered_Maps.Maps or an instance of Variable_Data (by way = of a variant record; even one which is forward declared). What would be the proper way to handle this sort of situation?