comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Question: Combination of Access and Constraining
Date: Thu, 20 Feb 2003 17:58:55 GMT
Date: 2003-02-20T17:58:55+00:00	[thread overview]
Message-ID: <3E5517AE.1040003@acm.org> (raw)
In-Reply-To: 1d13e1b4.0302200720.9666350@posting.google.com

Papandopulo wrote:
>>Pointers are inherently bad. Why not:
> 
> If they are ingerently bad why they are in
> the language ?

"Inherently bad" is not how I would put. However, large-scale pointer 
use is known to be the source of a family of errors. Pointers are needed 
far less in Ada than in some other languages, and it is a good idea to 
avoid them when you can.

>>function Fn (Arg : Tp) return Natural;
> 
> I have to use access type here. Since this is
> simplified example. I have function accepting
> several such array arguments each of which is
> optional (null).

This is still not a requirement to use access types. You can still say

Null_Tp : constant Tp (1 .. 0) := (1 .. 0 => False);

function Fn (Arg1 : Tp := Null_Tp; Arg2 : Tp := Null_Tp; ...)
return Natural;

Here you have a function with several such array arguments, each of 
which is optional, and each of which is a null array if not explicitly 
specified:

Tp1 : Tp (1 ..    10) := ...;
Tp2 : Tp (1 .. 1_000) := ...;
X   : Natural;
...
X := Fn (Tp1);         -- All except Arg1 are null
X := Fn (Arg2 => Tp2); -- All except Arg2 are null
X := Fn (Tp2, Tp1);    -- All except Arg1 & Arg2 are null

and so on.

-- 
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail




  parent reply	other threads:[~2003-02-20 17:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-20  8:06 Question: Combination of Access and Constraining Papandopulo
2003-02-20  9:00 ` tmoran
2003-02-20  9:29 ` Dmitry A. Kazakov
2003-02-20 15:20   ` Papandopulo
2003-02-20 16:20     ` Dmitry A. Kazakov
2003-02-20 17:58     ` Jeffrey Carter [this message]
2003-02-20 20:35       ` Yuri
2003-02-21  1:21         ` Jeffrey Carter
2003-02-21 22:53           ` Yuri
2003-02-23 12:34             ` Simon Wright
2003-02-23 17:50               ` Jeffrey Carter
2003-02-23 17:55               ` John R. Strohm
2003-02-23 17:48             ` John R. Strohm
2003-02-20 13:12 ` David C. Hoos, Sr.
2003-02-20 15:00 ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
2003-02-20  9:46 Grein, Christoph
replies disabled

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