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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Prime sieve Date: Wed, 27 May 2015 10:39:52 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 27 May 2015 17:38:43 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a3855fbfe1a666be9aefba0563039ed5"; logging-data="5089"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ROB0QAOCxDwBYM5/7rCAb+sUGNTIiGrc=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: Cancel-Lock: sha1:fOPXK76GQNEn/Z67bxtyuQ+OfUw= Xref: news.eternal-september.org comp.lang.ada:26022 Date: 2015-05-27T10:39:52-07:00 List-Id: On 05/27/2015 07:35 AM, montgrimpulo wrote: > with Ada.Text_IO; use Ada.Text_IO; > with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; > procedure Primes_by_Sieve is > task type Sieve is > entry Pass_on (Int : Integer); What happens when someone passes a negative value to Pass_On? If only a certain range of values is acceptable, it's better to use an appropriate (sub)type to prevent the use of invalid values. > type Sieve_Ptr is access Sieve; Access types are not needed for this problem. Not using this access type simplifies the body of Sieve. > task body P6n is > Limit : constant Integer := 2580976; This constant does not need to be typed. I always prefer named numbers to typed constants. The ARM only guarantees a range of -(2 ** 15) + 1 .. (2 ** 15) - 1 for Integer. This value makes your program non-portable. > while Num <= Limit loop Why not use a for loop? -- Jeff Carter "This school was here before you came, and it'll be here before you go." Horse Feathers 48