From: Sergio Silva <silva@elet.polimi.it>
Cc: silva
Subject: Initialize - behaviour??
Date: 1996/11/27
Date: 1996-11-27T00:00:00+00:00 [thread overview]
Message-ID: <329C601E.41C67EA6@elet.polimi.it> (raw)
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
next reply other threads:[~1996-11-27 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-11-27 0:00 Sergio Silva [this message]
1996-11-28 0:00 ` Initialize - behaviour?? Sergio Silva
1996-11-28 0:00 ` Paul Chardon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox