comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Prime sieve
Date: Wed, 27 May 2015 10:39:52 -0700
Date: 2015-05-27T10:39:52-07:00	[thread overview]
Message-ID: <mk4vf1$4v1$1@dont-email.me> (raw)
In-Reply-To: <dad3d5ce-c395-41a5-8845-f9400f2cb12d@googlegroups.com>

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

      parent reply	other threads:[~2015-05-27 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 14:35 Prime sieve montgrimpulo
2015-05-27 14:58 ` Paul Rubin
2015-05-27 15:01 ` Egil H H
2015-05-27 15:14 ` J-P. Rosen
2015-05-27 17:39 ` Jeffrey R. Carter [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox