TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jeffrey Carter <[log in to unmask]>
Reply To:
Jeffrey Carter <[log in to unmask]>
Date:
Tue, 21 Sep 2004 12:33:21 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
Alphonse, Prineesh wrote:

> I have a basic doubt regarding Access types in ADA.Suppose I have
> declared a variable as

> type Address is access Integer;
 > Pointer : Address;
>
> Now if I do a Increment Operation in ie Pointer := Pointer + 1; where
> will the Pointer Points to now. Will it be the next Byte or is it the
>  Next Integer Location ie pointer will move forward by Four Bytes.

As your compiler will tell you if you try to compile this, "+" is not
defined for type Address, nor is 1 a value of this type.

Be aware that access values are not necessarily the same as addresses in
Ada. The package System.Storage_Elements defines address arithmetic
operations and conversions between Address and an integer type, and the
generic package System.Address_To_Access_Conversions allows conversions
between addresses and access values, so it possible to do pointer
arithmetic in Ada, but it is very low level and in general it is not
needed. You will find that, unless you are building dynamic data
structures, you will rarely need pointers in Ada.

There is a type Address defined in package System, and there is the
'Address attribute, so it is considered poor practice to use the name
Address for something else.

The newsgroup comp.lang.ada is probably a better place for questions
like this than the Team-Ada mailing list.

Finally, the language is Ada, not ADA, after a woman who, having written
programs for Babbage's Analytical Engine, is considered the world's
first programmer.

--
Jeff Carter
"My mind is a raging torrent, flooded with rivulets of
thought, cascading into a waterfall of creative alternatives."
Blazing Saddles
89

ATOM RSS1 RSS2