From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.99.9 with SMTP id x9mr17586096ywb.151.1483363309960; Mon, 02 Jan 2017 05:21:49 -0800 (PST) X-Received: by 10.157.1.105 with SMTP id 96mr2695589otu.5.1483363309885; Mon, 02 Jan 2017 05:21:49 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!d45no1539521qta.0!news-out.google.com!u18ni4801ita.0!nntp.google.com!b123no5672966itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 2 Jan 2017 05:21:49 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.154.216.91; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 194.154.216.91 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <29380aa7-0c3b-4908-94c6-aa91f3996b42@googlegroups.com> Subject: Experimenting with the OOP features in Ada From: Laurent Injection-Date: Mon, 02 Jan 2017 13:21:49 +0000 Content-Type: text/plain; charset=UTF-8 X-Received-Bytes: 4881 X-Received-Body-CRC: 493519764 Xref: news.eternal-september.org comp.lang.ada:32992 Date: 2017-01-02T05:21:49-08:00 List-Id: 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