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,71c743c03ed191fe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-23 12:56:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!telocity-west!TELOCITY!sn-xit-03!sn-xit-01!sn-xit-04!sn-xit-08!supernews.com!12.120.28.37.MISMATCH!attla2!ip.att.net!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Beginer problem: variable array size References: <1032804973.357894@master.nyc.kbcfp.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc53 1032810822 12.234.13.56 (Mon, 23 Sep 2002 19:53:42 GMT) NNTP-Posting-Date: Mon, 23 Sep 2002 19:53:42 GMT Organization: AT&T Broadband Date: Mon, 23 Sep 2002 19:53:42 GMT Xref: archiver1.google.com comp.lang.ada:29291 Date: 2002-09-23T19:53:42+00:00 List-Id: >How very odd. You yourself posted a program which meets the OP's requirements. I lied. He might accept it, but it doesn't actually meet the stated spec. Of course no program could meet that spec. >In the terms you describe above, can you tell me what the limits are >of your program? >> type List_Type is array (Integer range <>) of Integer; Clearly has a limit of Integer'range inputs. If Integer'size = 16, that's 65,536 inputs (if I understand correctly the rules for the lower bound of a concatenation). If Integer'size = 32, there's probably a limit much smaller than 2**32 set by recursion stack growth. I can't tell you accurately what that might be without finding out more about how the stack is used by the program as compiled on a particular system. The program used a quadratic sort. Since it prints during the sort, you could probably have a good size input before there was a noticeable, non-IO, delay, but that would happen even on a reasonably fast (ca 2002) machine when you got into a few million inputs. The lack of a literal number, or a comment saying the above, means the limit is hidden from a quick scan - but there is a limit. > There is a fundamental difference between a program which has a > wired-in size limit and a program which is bound by available > memory, or even available address space. For one thing, when the > latter program is moved to a system with more resources, it will > hndle larger inputs. The former program will be stuck at its limit > until it's revised. I agree there's a big difference between a program with a literal numeric constant as a limit and a program that adapts to the resources available, and the latter is normally better. But the former at least documents clearly what the limit is. The adaptable program should say what its limits are, or how to calculate those limits on a particular machine. How often have you seen that, vs leaving it to experiment and Constraint_Error or Storage_Error or "CPU time exceeded"? It's like failing to do error analysis for a numeric program, or using type Integer rather than an explicitly declared type. The sloppy approach is commonly done (I don't claim purity myself), but it shouldn't be encouraged.