From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: Usefulness of classwide "out" parameter
Date: 1999/03/17
Date: 1999-03-17T00:00:00+00:00 [thread overview]
Message-ID: <7cpa8v$gor$2@plug.news.pipex.net> (raw)
In-Reply-To: 7cikku$d4k$1@nnrp1.dejanews.com
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
-------------------------------------
prev parent reply other threads:[~1999-03-17 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-15 0:00 Usefulness of classwide "out" parameter okellogg
1999-03-15 0:00 ` Matthew Heaney
1999-03-15 0:00 ` Joachim Schroeer
1999-03-17 0:00 ` Nick Roberts [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox