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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,86865b0115f7ab4f,start X-Google-Attributes: gid103376,public From: Sergio Silva Subject: Initialize - behaviour?? Date: 1996/11/27 Message-ID: <329C601E.41C67EA6@elet.polimi.it>#1/1 X-Deja-AN: 201051778 cc: silva content-type: text/plain; charset=us-ascii organization: Politecnico di Milano mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 3.01Gold (X11; I; SunOS 4.1.4 sun4m) Date: 1996-11-27T00:00:00+00:00 List-Id: Hello everyone, I have a problem on understanding the correct behaviour of initialize. I expected an object not to be accessible to other procedures until initialization has finished but that does not happen in the example below. I have the following tagged type: type Watcher_Type is new Limited_Controlled with record FileOne : Log_File.File_Type; Scanned : Log_File.Positive_Count := 1; end record; with the follwoing initialize procedure: procedure Get_Ready (Watcher_object : in out Watcher_Type_Logger) is File_Name : String := "Logged.log"; I : Integer :=10; begin Create(File => Watcher_object.FileOne, Mode => Out_File, Name => File_Name(1..I)); exception when others => Put_Line("WATCHER initialize logger"); end Get_Ready; and a procedure that uses the file, which looks like: procedure Log (Watcher: in out Watcher_Type_Logger; Data : in Data_Type;) is Input_Record; begin Input_Data.Data := Data; Write( Watcher.FileOne,Input_Record);---- exception when others => Put_Line ("WATCHER log"); end Log; If a task calls procedure Log at the very begining of an execution, it happens that the attempt to write to the file occurs before the file is created, so an exception is raised. I have looked at the LRM Section 7.6 and nothing specifies that initialization must end before any access to the object is allowed. Does any body know anything about what the behaviour should be? And, if the behaviour I am getting is correct: What may be the motivation to allow such a thing? Thanks for your comments, Sergio P.S. I am compiling with Gnat 3.07 P.P.S. I have solved the problem, of course by explicitly calling a procedure that performs the initialization... -- ----------------------------------------------------------------------------- Sergio Silva-Barradas Dip.to di Elettronica e Informazione Politecnico di Milano Ph: +(39)(2) 2399 3638 P.zza Leonardo da Vinci 32 Fax: +(39)(2) 2399 3411 I20133 Milan, Italy e-mail: silva@elet.polimi.it