Pointers and references: Difference between revisions

(Added BBC BASIC)
Line 6:
Create a pool specific access type for an integer
<lang ada>type Int_Access is access Integer;
Int_Acc : Int_Access := new Integer '(5);</lang>
A pool specific access type can be constrained to never be null. For such pointers the compiler can omit checks of being null upon dereferencing.
<lang ada>type Safe_Int_Access is not null access Integer;</lang>
Line 18:
The attribute 'Access (and also 'Unchecked_Access) is used to get a pointer to the object. Note that the object has to be declared ''aliased '' when it has to be referenced by a pointer. General access types can also be constrained to exclude null:
<lang ada>type Safe_Int_Ptr is not null access all Integer;</lang>
 
===Addresses===
Ada does not provide pointer arithmetic, but does allow evaluation of the address
Anonymous user