From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.IIfIc3CB/+nKo+wKq8+a0g.user.gioia.aioe.org!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Newbie question # 2 Date: Thu, 06 Aug 2020 19:56:23 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <8b2858e0-e69c-4a22-ad51-a6a7c51e7a7do@googlegroups.com> NNTP-Posting-Host: IIfIc3CB/+nKo+wKq8+a0g.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:GtbdMd0SdzdTD+9DNGh6BDoXqWg= Xref: reader01.eternal-september.org comp.lang.ada:59674 List-Id: Ian Douglas writes: > In PHP, let's say we have a variable $fruit which contains the string > "banana". > > In PHP, if I do $$fruit, then it creates a variable $banana, which I > can then do things with. > > Does Ada support any such concept of taking the contents of one > variable and using THAT as a variable? > > I'm reading in a file which has a name of an object followed by some > properties so I want to use the name as a variable ... File is > something I created, so it's not some random stuff, and the variables > will be existing already. I'd think of a record type to contain the properties, and then a map from object name to properties: type Properties is record Length : Positive; Width : Positive; end record; package Object_Maps is new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String, Element_Type => Properties); Objects : Object_Maps.Map;