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 autolearn=ham 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-22 11:24:40 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Looping over a tagged record? References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Fri, 22 Jun 2001 18:24:40 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 993234280 24.7.82.199 (Fri, 22 Jun 2001 11:24:40 PDT) NNTP-Posting-Date: Fri, 22 Jun 2001 11:24:40 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:9038 Date: 2001-06-22T18:24:40+00:00 List-Id: Note that doing a 'read or 'write of a record makes the compiler generate code to sequentially visit each component of that record, calling a 'read/write routine for each. You get to supply those 'read/write routines if you want - they don't actually have to do IO at all, but could do something else entirely. Is that what you meant by "looping over a [tagged] record"? >Ada.Streams_IO, however, seems to be a built in method for doing >most of what I need. The only problem is that when I'm reading >the stuff back in I won't be able to use the file tags to tell >Ada what kind of data I'm reading. That won't be known at >compile time. So I'll need to build the kind of case switch You can use 'Class'Read or 'Class'Input to have dispatching on the particular type at run time. You don't need to know about all the possible descendants of a type when you compile your input routine. You can later create a new descendant with an overriding input routine to be called for that new type. If your input data was externally supplied, you'll of course have to write code to translate to an Ada tag from however it decides what "type" an object is, and any time you add a new input possibility you'll have to update that code to handle it. But no language, compiler, or computer can tell what to do with a brand new, unexpected, type-of-object indicator, until you tell it. A case statement or the equivalent is how you tell it, and the case statement will need a new branch to understand what to do with a new record type.