From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Newbie question # 2
Date: Thu, 6 Aug 2020 21:41:35 +0200 [thread overview]
Message-ID: <rghmdc$13j6$1@gioia.aioe.org> (raw)
In-Reply-To: 8b2858e0-e69c-4a22-ad51-a6a7c51e7a7do@googlegroups.com
On 06/08/2020 20:40, Ian Douglas wrote:
> I did try Google search and assorted books but could not find answer.
>
> 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.
You cannot, because you do not know its name before program run, so you
will have to keep on using indirection "$fruit" rather than the direct
name "banana".
> Does Ada support any such concept of taking the contents of one variable and using THAT as a variable?
Sure. Indirection is supported in almost all known programming
languages. You can have a map: string->value. Here string is "banana",
or an array: index->value etc.
> 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.
This would be filling a predefined map reading it from the file in the
form of (key,value) pairs. Just deserialization of a map with fixed keys.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
prev parent reply other threads:[~2020-08-06 19:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-06 18:40 Newbie question # 2 Ian Douglas
2020-08-06 18:56 ` Simon Wright
2020-08-06 19:41 ` Ian Douglas
2020-08-06 21:10 ` Simon Wright
2020-08-07 11:28 ` Ian Douglas
2020-08-06 19:20 ` Niklas Holsti
2020-08-06 19:45 ` Ian Douglas
2020-08-06 20:08 ` Niklas Holsti
2020-08-06 19:41 ` Dmitry A. Kazakov [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox