comp.lang.ada
 help / color / mirror / Atom feed
From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: ADA 95 Questions.
Date: 1998/06/18
Date: 1998-06-18T00:00:00+00:00	[thread overview]
Message-ID: <35892484.9514B8E@elca-matrix.ch> (raw)
In-Reply-To: 35890E1B.2A19914F@tech.swh.lv


Maxim Senin wrote:
> 
> Hi all!
> 
> I have some ADA questions:
> 
>    * Is ADA garbage collector?

Ada allows a garbage collector, but does not require it. I think there is
currently no Ada implementation that provides garbage collection. Note that
controlled types eliminate much of the need for GC.

>    * Can I do something like in C++?:
>      int[] array = new int [100];

type Int_Array is array (Positive range <>) of Int;
type Int_Array_Access is access Int_Array;

X : Int_Array_Access := new Int_Array(1 .. 100);

>      How can I dinamically allocate array?

see above.

>      How to copy array elements? I mean, can I copy part of array as
>      it is fo strings in this manner:
>      s1 : String := "Hello";
>      s2 : String := "World!";
>      begin
>          s1 (1..4) := s2 (2..5); -- will result s1 = "orllo"
>      end

The code is correct, but the reesult will be s1 = "orldo".

>      or like Java's System.arraycopy() routine?
>    * What's the difference between A, A'Class and A'Access? (Seems
>      A'Access is similar to C's &A)?

A'Class is not an access type. It is an indefinite type that can hold a value
of A or any of A's subclasses (i.e. any type derived directly of indirectly
from A). A'Access denotes a pointer to the object A. A'Access does not mean
anything when A is a type. I would recommend reading about this in a book (not
the RM, it's too hard to read when leaning the language). 

>    * What's the difference between following procedure defs:
>      procedure p (a : C);

the parameter must be of type C.

>      procedure p (a : C'Class);

the parameter must be C or any type derived from C (if C is tagged).

>      procedure p (a : C'Access);

does not compile.

>      procedure p (a : access C);

the parameter must be a pointer to an object of type C.

>      procedure p (a : in out C); ?

the parameter can be both read and written, as opposed to the other cases
above (except access).

>    * What means procedure/function parameter without "in/out"
>      specifier (e.g. procedure p (a : Integer; b : in Boolean; c : out
>      Float; d : in out Double))?

if there is no mode specified, then the mode is in.




       reply	other threads:[~1998-06-18  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <35890E1B.2A19914F@tech.swh.lv>
1998-06-18  0:00 ` Mats Weber [this message]
1998-06-19  0:00   ` ADA 95 Questions falis
1998-06-21  0:00     ` Robert Dewar
replies disabled

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