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,a0224dc3d1e52f3d X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Streams and Concurrency Date: 1999/01/04 Message-ID: #1/1 X-Deja-AN: 428735839 References: <76c3tv$acs@bgtnsc02.worldnet.att.net> <76cat4$2ldc$1@news.gate.net> <76dn7b$a35@bgtnsc03.worldnet.att.net> <76e4rg$bsr$1@nnrp1.dejanews.com> Organization: The Mitre Corp., Bedford, MA. Newsgroups: comp.lang.ada Date: 1999-01-04T00:00:00+00:00 List-Id: In article <76e4rg$bsr$1@nnrp1.dejanews.com> dennison@telepath.com writes: > But this solution only works for objects that are part of the same class > hiearchy. That's too restrictive. I'd want to be able to use any type. It > sounds like Tuck's generic suggestion is the way to go. Wonderful opertunity for generic children. ;-) Create a (generic) package that encapsulates the stream and the locking mechanism. This package would then have a generic child package that you instantiate once for each type you want to write to the stream. (And now for the really tricky part...) If you want to be able to read the mixed stream without knowing what type of value appears next, you have to have a parent type in the parent generic, or a parent access type, and a read operation declared there which returns objects of the class rooted at this type. You can then use a fairly common Ada idiom (a declare block with a class-wide object initialized by a function) to make the contents of the stream available. The case where you know the structure of the stream, or as Tucker suggested, have markers in the stream, is much easier to program. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...