comp.lang.ada
 help / color / mirror / Atom feed
* Exposing agreggate members of a class
@ 1998-12-30  0:00 David Botton
  1998-12-30  0:00 ` Tom Moran
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: David Botton @ 1998-12-30  0:00 UTC (permalink / raw)


Given:

with GCanvas_Package; use GCanvas_Package;

type GWindow_Object is tagged with private;
type GWindow_Pointer is access all GWindow_Object;

private:

type GWindow_Object is tagged
   record
        Canvas : GCanvas_Object;
   end record;

What is the cleanest way to give access to the Canvas by reference in a way
that will not require Unchecked Programming

What I don't want:

    function Get_Canvas( window : in GWindow_Object ) return GCanvas_Pointer
is
    begin
        return window.Canvas'Unchecked_Access;
    end Get_Canvas;

Which on top of the Unchecked_Access issue means that consumers of such a
class would have to dereference first to use the GCanvas_Object methods:

declare
    Canvas : GCanvas_Pointer := Get_Canvas( window );
begin
    Draw_Line(Canvas.all, 10, 10, 100, 100);
end;

Of course you could write the methods to accept GCanvas_Pointer's, but I
want to avoid the use of Access variables when possible.

Thanks,
David Botton







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-01-06  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-30  0:00 Exposing agreggate members of a class David Botton
1998-12-30  0:00 ` Tom Moran
1998-12-31  0:00 ` LeakyStain
1998-12-31  0:00   ` David Botton
1999-01-03  0:00 ` Simon Wright
1999-01-06  0:00 ` Matthew Heaney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox