From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: access attributes from record
Date: Tue, 13 Nov 2007 01:25:35 +0200
Date: 2007-11-13T01:25:35+02:00 [thread overview]
Message-ID: <4738d236$0$3500$39db0f71@news.song.fi> (raw)
In-Reply-To: <5prshlFsgf8dU1@mid.individual.net>
Dominik F�ssler wrote:
> Hi
>
> Is it possible to determine the 'Length of a record, loop
> it an get attribute name/value/type?
If I understand your question correctly, you have a record type (or
an object of a record type) and you want to write a loop that
traverses the record's components, one by one from the first to the
last, and somehow learns the name, type, and value of each
component? A bit as if the record were an array, and you were
traversing over the elements of the array, but in the record case
the components have names instead of array indices, and may have
different types?
You cannot do this within you Ada application itself, but you can
do something similar (at least for component names and types, but
not for values) by means of the Ada Semantic Interface Standard
(ASIS), in a metaprogramming fashion. That is, you pass the Ada
record definition (embedded in a compilable Ada program) to an
ASIS-enabled Ada compiler such as GNAT, which produces an ASIS
data-base, and then you write a second Ada (meta-)program to query
the ASIS data-base for the record structure. But as this is
meta-programming (not reflective programming) you only have access
to static type information, not to dynamic values.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2007-11-12 23:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-12 20:49 access attributes from record Dominik Fässler
2007-11-12 21:18 ` Adam Beneschan
2007-11-13 5:44 ` Dominik Fässler
2007-11-12 23:25 ` Niklas Holsti [this message]
2007-11-13 5:51 ` Dominik Fässler
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox