From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a0c:aa45:: with SMTP id e5mr5474192qvb.44.1615994428486; Wed, 17 Mar 2021 08:20:28 -0700 (PDT) X-Received: by 2002:a25:1883:: with SMTP id 125mr4689302yby.465.1615994428380; Wed, 17 Mar 2021 08:20:28 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 17 Mar 2021 08:20:28 -0700 (PDT) In-Reply-To: <6aad7864-7b88-4e73-b4fe-f4cd30673b28n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: <6aad7864-7b88-4e73-b4fe-f4cd30673b28n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <82149dfa-91b2-481c-9404-1ca2370c3714n@googlegroups.com> Subject: Re: Attempting to create file i task From: Shark8 Injection-Date: Wed, 17 Mar 2021 15:20:28 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61591 List-Id: On Wednesday, March 17, 2021 at 6:39:05 AM UTC-6, reinert wrote: > Hello, > > Assume task A starts subsequentially two times sub-sequentially (but not overlapping in time). It creates and closes a file: > > define > my_file : File_Type; > begin > Create (File => my_file, Mode => Out_File, Name => my_file_name); > ..some statements... > Close(my_file); > end; > > I now have the strange experience that task A overwrites the file > created the first time? Any idea where to look for the error? > > reinert What I would do in this situation: (1) Make a function that opens the file, on the exception where it does not exist it creates the file. (2) For my own convenience, I would likely wrap the file-type in a controlled object which would close the file on Finalize, and has a "Get_Stream" method. (3) Combine #1 and #2 so that creating #2's type does #1. (4) Given the above, adding some debugging information is rather trivial. (5) Once things are debugged, you can delete the debugging-info and you still have a useful framework for handling files.