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,abbaab2e39561193 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-05 04:49:06 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread1.news.atl.earthlink.net.POSTED!d9c68f36!not-for-mail Message-ID: <3FA8F1B8.9070408@noplace.com> From: Marin David Condic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (OEM-HPQ-PRS1C03) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Variant vs. Tagged Type References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 05 Nov 2003 12:49:05 GMT NNTP-Posting-Host: 209.165.24.37 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.atl.earthlink.net 1068036545 209.165.24.37 (Wed, 05 Nov 2003 04:49:05 PST) NNTP-Posting-Date: Wed, 05 Nov 2003 04:49:05 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:2076 Date: 2003-11-05T12:49:05+00:00 List-Id: Well, in most respects, a tagged type is just a special case of a variant record. (Conceptually) The "variant" is the tag. In that sense, most access should be just as fast either way - depending on compilers and optimizations, etc. (The only way to know for sure is to measure with *your* compiler in *your* environment with code that is typical of what you want to do. Maybe Ada should develop a performance benchmark suite to test some of these things?) However, you do have to be careful with tagged types in that some things cannot be done statically at compile-time. Things like dispatching to operations on the tagged type. In general, the static things should be no worse than any other sort of operation on a variant record, but if you use features that are dynamic, you'll incur some additional overhead. (How much? You can only know by checking into your compiler.) OTOH, you also need to ask just how critical the time concerns are. In many apps, the slight additional overhead connected to tagged types is not enough to cause any sort of problem. In other apps, you might be so tight on the time budget that even the variant record approach might be too much to bear. (The code has to look up the variant at run time to know how to interpret the record, right? That's not free.) Lots of designers get their panties in a bunch over performance concerns when a step back and a deep breath reveals its all "the small stuff." Like life in general, we often worry about things that never happen. MDC Frank Piron wrote: > Hi, > is it possible to make some general statements > concerning the alternative variant vs. tagged > type with respect to runtime performance? > For example: > if we have an array A 1) of type access to a variant > 2) of type access 'Class > what can be said about the runtime performance > of the expression > A(I).? > Thanks in Advance, > Frank > -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jsf.mil/NSFrames.htm Send Replies To: m o d c @ a m o g c n i c . r "So if I understand 'The Matrix Reloaded' correctly, the Matrix is basically a Microsoft operating system - it runs for a while and then crashes and reboots. By design, no less. Neo is just a memory leak that's too hard to fix, so they left him in... The users don't complain because they're packed in slush and kept sedated" -- Marin D. Condic ======================================================================