Created
August 21, 2012 18:50
-
-
Save flyx/3418293 to your computer and use it in GitHub Desktop.
Trying to use Ada 2012 features
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO; | |
procedure Test is | |
type Int_Array is array (1 .. 64) of aliased Integer; | |
subtype Index is Integer range 1 .. 4; | |
type Ref_Element (Data : not null access Integer) is limited null record | |
with Implicit_Dereference => Data; | |
package Foo is | |
type My_Type is tagged private | |
with Variable_Indexing => Element; | |
function Element (Object : aliased in out My_Type; X, Y, Z : Index) return Ref_Element; | |
private | |
type My_Type is tagged record | |
Elements : Int_Array := (others => 0); | |
end record; | |
end Foo; | |
package body Foo is | |
function Element (Object : aliased in out My_Type; X, Y, Z : Index) return Ref_Element is | |
begin | |
return Ref_Element'(Data => Object.Elements (X + (Y - 1) * 4 + (Z - 1) * 16)'Access); | |
end Element; | |
end Foo; | |
Object : aliased Foo.My_Type; | |
Cur : Integer; | |
begin | |
Object (1, 1, 1) := 4; | |
Object (3, 1, 2) := 16; | |
for I in Index'Range loop | |
Cur := Object (I, I, I); | |
Ada.Text_IO.Put_Line (Cur'Img); | |
end loop; | |
end Test; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New output:
test.adb:34:04: missing argument for parameter "Y" in call to "Element" declared at line 16
test.adb:35:04: missing argument for parameter "Y" in call to "Element" declared at line 16
test.adb:38:14: missing argument for parameter "Y" in call to "Element" declared at line 16