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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e8cf506f89b5d0a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-19 15:30:26 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!titan03.ksc.nasa.gov!niven.ksc.nasa.gov!usenet From: "Samuel T. Harris" Newsgroups: comp.lang.ada Subject: Re: Looping over a tagged record? Date: Tue, 19 Jun 2001 17:20:09 -0500 Organization: Raytheon Aerospace Engineering Services Message-ID: <3B2FD019.AC7B00F2@gsde.hou.us.ray.com> References: <9god9a$g04$0@208.164.98.151> Reply-To: samuel_t_harris@raytheon.com NNTP-Posting-Host: sstf-fw.jsc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; U; IRIX64 6.2 IP19) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:8901 Date: 2001-06-19T17:20:09-05:00 List-Id: Pascal Obry wrote: > > "M R Goodwin" writes: > > > Hi! > > > > This is a part practical, and a part 'I wonder' type problem. > > I have a tagged record that is pretty big. Most, but not all of > > the elements in it are a bounded string type. Because I don't feel > > like the typing and all I would need to do to assign and later change > > values, I was wondering if there is anyway to loop over all elements in > > the record, checking their type and then taking the right action... > > And now to answer your question: No there is no way to iterate through record's > fields. > > Pascal. I'm missing the original posting so here are my thoughts bases on this snippet. Given that Mr. Goodwin know what to do which each field type and given the every way to get a record object implies the code knows which record to expect, then I don't see why Mr. Goodwin needs to "iterate" on each field since the code will know which fields to expect and should not necessarily need to query the type of each field. It seems to me that given the operation in question being define for scalar types, then one can easily define the operation for each composite type as one defines them. In other words, the type declaration should define how said operation will be perform on the components. The problem statement appears dubious to me as well. Now, if Mr. Goodwin is simply trying to avoid lots of boilerplate typing when applying this operation to composite types, especially records type which are by definition heterogenous, then he can either use generics such as I use to implement general width/image/value function for all types OR he can use an ASIS based tool to find his composite types and "generate" the operation body specific to the contents of the composite type. -- Samuel T. Harris, Senior Software Engineer II Raytheon, Aerospace Engineering Services "If you can make it, We can fake it!"