-
Notifications
You must be signed in to change notification settings - Fork 0
/
spk02.adb
31 lines (27 loc) · 816 Bytes
/
spk02.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
procedure Main is
package Data is
type AI is access all Integer;
function Foo (x : AI) return AI;
function Bar (x:Integer) return Integer is (x);
procedure Test (x : in out Integer);
end Data;
package body Data is
-- Foo is an accessor function, it is not accepted by
-- our rules, contrary to Rust.
function Foo (x:AI) return AI is -- observed (x)
begin
return x; --move of (X) occurs here
--ERROR, cannot move (X): observed path (X)
end Foo;
procedure Test (x : in out Integer) is
begin
x := 42;
end Test;
end Data;
use Data;
X : aliased Integer := 44;
Y : aliased AI := X'Access; -- move of (X) occurs here
begin
Foo(Y).all := 5; -- observe of (Y) occurs here
Test(Foo(Y).all);
end Main;