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.2 required=5.0 tests=BAYES_00,FROM_WORDY, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f4ee91990d68693 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: Usefulness of classwide "out" parameter Date: 1999/03/17 Message-ID: <7cpa8v$gor$2@plug.news.pipex.net>#1/1 X-Deja-AN: 455893692 References: <7cikku$d4k$1@nnrp1.dejanews.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom) Newsgroups: comp.lang.ada Date: 1999-03-17T00:00:00+00:00 List-Id: I think 'out' parameters of a classwide type will be useful in some situations. I am particularly thinking of a 'wrapper' procedure which redispatches on the classwide parameter. For example, consider an abstract tagged type T, and suppose that it has an abstract procedure: procedure Create (Obj: out T) is abstract; so that all types derived from T must have a 'Create' procedure, which presumably initialises an object of that type in the appropriate way. Now, supposing you wanted to monitor the creation of all objects of types derived from T (perhaps writing a message onto a log file for each occurrence). You could do this by declaring a 'wrapper' procedure: procedure Monitored_Create (Obj: out T'Class) is begin Put_Line(Log_File,"Creating object of type " & Ada.Tags.Expanded_Name(Obj'Tag)); Create(Obj); end; This procedure outputs a message onto a log file (using the known tag of the object actually passed), and then redispatches on that object to the requisite 'Create' procedure. It may be that 'out' parameters of a classwide type are not likely to be used very often, but, like many aspects of the language, I suspect they will be useful every now and then! (A bit like me, really ;-) ------------------------------------- Nick Roberts -------------------------------------