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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!nwrdny01.gnilink.net.POSTED!0f19ed38!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <1087410710.477506@master.nyc.kbcfp.com> Subject: Re: A simple ADA puzzle (I haven't the answer) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: <8yXCc.548$Av3.500@nwrdny01.gnilink.net> Date: Fri, 25 Jun 2004 15:30:12 GMT NNTP-Posting-Host: 151.203.203.234 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny01.gnilink.net 1088177412 151.203.203.234 (Fri, 25 Jun 2004 11:30:12 EDT) NNTP-Posting-Date: Fri, 25 Jun 2004 11:30:12 EDT Xref: g2news1.google.com comp.lang.ada:1888 Date: 2004-06-25T15:30:12+00:00 List-Id: "Randy Brukardt" wrote in message news:KZedneo665VD3EbdRVn-uA@megapath.net... > I really see no downside to requiring this support - customers want it and > try to use it all the time; it wouldn't have a performance impact on types > that already work; and the restriction No_Implicit_Heap_Allocation would be > used if you really had to avoid the overhead. But I'm in the minority on > this one. As a recent convert, I can tell you how I became convinced of this point of view. When it comes to implementing variant records, there are two ends of a spectrum where the correct course of action is easily determined: 1) If the size of the record does not vary much, e.g. if the type discriminants allow the length of a character array to vary from 1 to 20 characters, then you might as well eschew the overhead of heap allocation and simply create the object "in place". 2) If the size of the record varies widely depending on the discriminants, so that a variable of this type can store values that vary from 10 bytes to 10,000,000 bytes in length, then either the programmer or the compiler should implement these objects using the heap. We can complain about the overhead, but there is no other way. But what about the cases between these two extremes? Assume that we are writing code that is to be ported to multiple platforms. Assume further that the variations in size of an object of our record type are large enough so that on platforms with tight memory constraints (say embedded DOS) would require heap allocation, but small enough that static allocation is an option on other platforms. How do we write something that works and is optimal for all platforms? Ideally, shouldn't the programmer write what is desired, and let the compiler decide the most appropriate way to implement it for the given platform? When this argument occurred to me, it was one of those "Eureka!" moments. Although it is too late to get this into Ada 0x, perhaps we can get this changed for Ada 1x.