From: Laurent <lutgenl@icloud.com>
Subject: Experimenting with the OOP features in Ada
Date: Mon, 2 Jan 2017 05:21:49 -0800 (PST)
Date: 2017-01-02T05:21:49-08:00 [thread overview]
Message-ID: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> (raw)
Hi
Happy new year!
Trying some OOP features in Ada. So not sure if everything is actually
correct.
Comments are welcome.
So I have done a little test. Link at the end.
I get the following error:
raised CONSTRAINT_ERROR : my_strings-handle.adb:14 access check failed
Which I don't understand. Sounds like the object no longer exists?
test.adb:
with Ada.Text_IO;
with Ada.Exceptions;
with Gnat.Traceback.Symbolic; use Gnat;
with Base_Types.Antibiotics;
with My_Strings;
with My_Strings.Handle;
procedure Test is
package SS renames My_Strings.Handle;
Test_Antibiotic : Base_Types.Antibiotics.Object
:=Base_Types.Antibiotics.Create (Name => "Test Antibiotic 1",
Code_SIL =>"123",
CMI => "1",
SIR => "S");
Test_String : My_Strings.Handle.My_Safe_String := SS.Create ("Test
single 1");
begin
Ada.Text_IO.Put_Line (Test_String.Value);
Test_String := SS.Create ("Test single 2");
Ada.Text_IO.Put_Line (Test_String.Value);
Test_String := SS.Create ("Test single 3");
Ada.Text_IO.Put_Line (Test_String.Value);
Ada.Text_IO.Put_Line (Test_String.Value);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Test record run 1:");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Name: " & Test_Antibiotic.Name_Value);
Ada.Text_IO.Put_Line ("Code SIL: " & Test_Antibiotic.Code_SIL_Value);
Ada.Text_IO.Put_Line ("CMI: " & Test_Antibiotic.CMI_Value);
Ada.Text_IO.Put_Line ("SIR: " & Test_Antibiotic.SIR_Value);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Test record run 2:");
Ada.Text_IO.New_Line;
Test_Antibiotic := Base_Types.Antibiotics.Create_Name (Name => "Test
Antibiotic 2");
Ada.Text_IO.Put_Line ("Name: " & Test_Antibiotic.Name_Value);
Test_Antibiotic := Base_Types.Antibiotics.Create_Code_SIL (Code_SIL =>
"amc");
Ada.Text_IO.Put_Line ("Code SIL: " & Test_Antibiotic.Code_SIL_Value);
Test_Antibiotic := Base_Types.Antibiotics.Create_CMI (CMI => "2");
Ada.Text_IO.Put_Line ("CMI: " & Test_Antibiotic.CMI_Value);
Test_Antibiotic := Base_Types.Antibiotics.Create_SIR (SIR => "R");
Ada.Text_IO.Put_Line ("SIR: " & Test_Antibiotic.SIR_Value);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("Test record run 3:");
Ada.Text_IO.New_Line;
Test_Antibiotic := Base_Types.Antibiotics.Create_Name (Name => "Test
Antibiotic 3");
Test_Antibiotic := Base_Types.Antibiotics.Create_Code_SIL (Code_SIL =>
"gen");
Test_Antibiotic := Base_Types.Antibiotics.Create_CMI (CMI => "8");
Test_Antibiotic := Base_Types.Antibiotics.Create_SIR (SIR => "I");
Ada.Text_IO.Put_Line ("Print run 3:");
Ada.Text_IO.Put_Line ("Name: " & Test_Antibiotic.Name_Value);
Ada.Text_IO.Put_Line ("Code SIL: " & Test_Antibiotic.Code_SIL_Value);
Ada.Text_IO.Put_Line ("CMI: " & Test_Antibiotic.CMI_Value);
Ada.Text_IO.Put_Line ("SIR: " & Test_Antibiotic.SIR_Value);
exception
when Err : others =>
Ada.Text_IO.Put_Line ("Problem: " &
Ada.Exceptions.Exception_Information (Err));
Ada.Text_IO.Put_Line (Traceback.Symbolic.Symbolic_Traceback (Err));
end Test;
Terminal output:
Test single 1
Test single 2
Test single 3
Test single 3
Test record run 1:
Name: Test Antibiotic 1
Code SIL: 123
CMI: 1
SIR: S
Test record run 2:
Name: Test Antibiotic 2
Code SIL: amc
CMI: 2
SIR: R
Test record run 3:
Print run 3:
Problem: raised CONSTRAINT_ERROR : my_strings-handle.adb:14 access check
failed
Why does it fail on the 3rd run? It works the 2 first ones?
The programm depends on Dmitry A. Kazakov's Simple Components.
The My_Strings package is copied from the docs of this library.
Link to the files on Git:
https://github.com/Chutulu/BCI_2.git
Thanks
Laurent
next reply other threads:[~2017-01-02 13:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-02 13:21 Laurent [this message]
2017-01-02 14:11 ` Experimenting with the OOP features in Ada Brian Drummond
2017-01-02 14:43 ` Brian Drummond
2017-01-02 16:27 ` Laurent
2017-01-03 13:01 ` Brian Drummond
2017-01-03 13:57 ` Laurent
2017-01-03 14:31 ` Dmitry A. Kazakov
2017-01-03 17:07 ` G.B.
2017-01-03 20:42 ` Dmitry A. Kazakov
2017-01-04 12:18 ` Laurent
2017-01-04 12:44 ` Dmitry A. Kazakov
2017-01-05 11:41 ` Laurent
2017-01-05 13:02 ` Dmitry A. Kazakov
2017-01-05 13:11 ` AdaMagica
2017-01-04 15:09 ` Shark8
2017-01-05 11:54 ` Laurent
[not found] ` <85ef59f3-bcbe-4630-9b4d-8285623ab456@googlegroups.com>
2017-01-03 12:48 ` Brian Drummond
2017-01-03 13:43 ` Laurent
2017-01-02 15:54 ` Laurent
2017-01-02 16:41 ` Dmitry A. Kazakov
2017-01-02 18:50 ` Laurent
2017-01-02 20:55 ` Dmitry A. Kazakov
2017-01-03 13:39 ` Laurent
2017-01-03 14:40 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox