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.0 required=3.0 tests=BAYES_20 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: General circular buffer example not tied to any specific type Date: Thu, 24 Sep 2020 06:39:43 +0200 Organization: Adalog Message-ID: References: <6ca9747e-698f-4d60-8e23-b883da5d9f38o@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 24 Sep 2020 04:39:42 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="72f0c219c92fbd281301e820b884b418"; logging-data="25391"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KYLR6jIeQ0YXnI8IgD+ed" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 Cancel-Lock: sha1:WSBQNE19pO9hS+I3S9eOerF3Lk4= In-Reply-To: Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:60268 List-Id: Le 24/09/2020 à 06:10, nimaopatel121@gmail.com a écrit : > On Saturday, 4 July 2020 22:30:28 UTC+5:30, Daniel wrote: >> Hello, any theoric >> example of buffer i can find is always tied to an specific type. >> >> I'm looking for any example of ravenscar buffer able for using any type of data at the same time. >> >> I suppose it will need to serialize all data and manipulate it as a group of bytes. >> >> Does any body knows any example of this written in Ada? > Hmmm, you know, Ada is a strongly typed language, therefore what you put in a buffer must have a well defined type. There are two possibilities: 1) If you can accept several buffers, one for each type, make it generic and instantiate it as many times as you need 2) Make a buffer of Stream_Elements, and use the streaming attributes ('Read, 'Write) to turn any type into stream elements. Ada.Streams.Stream_IO can also be handy in some cases. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr