comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Help: Tagged Types
Date: 16 Nov 2001 12:35:54 -0500
Date: 2001-11-16T17:38:23+00:00	[thread overview]
Message-ID: <un11mty85.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: FIbJ7.1600$7e3.505107@news2-win.server.ntlworld.com

"chris.danx" <chris.danx@ntlworld.com> writes:

> Hi,
> 
> If we have a decendant of type gwindows.windows.window_type, gl_window_type,
> and override it's create procedure, does the following call the create
> procedure for gwindows.windows.window_type?

No, it dispatches.

You want:

       gwindows.windows.create (gwindows.windows.window_type(window));


Critique of GWindows:

In general, it's best if "create" functions are _not_ primitive
operations of the type, for precisely this reason. The derived types
should have a different "create" function, because they will normally
have additional parameters, and the compiler should help the user call
the correct one.

One way to do this is to put the Create functions in a local nested
package. 

> 
> -- create a window;
> --
> procedure Create
>      (Window     : in out gl_window_type;
>       Title      : in     gwindows.GString     := "";
>       Left       : in     Integer     := GWindows.Constants.Use_Default;
>       Top        : in     Integer     := GWindows.Constants.Use_Default;
>       Width      : in     Integer     := GWindows.Constants.Use_Default;
>       Height     : in     Integer     := GWindows.Constants.Use_Default;
>       Is_Dynamic : in     Boolean     := False) is
>    begin
>       gwindows.windows.create (gwindows.windows.window_type'class(window));
>       ...
>       ...
>    end create;
> 
> It compiles ok, but does it do what I intend.  It has to initialise a window
> of type gl_window_type as if it were gwindows.windows.window_type, then call
> some other routines.  All I need to know is if this is the correct method to
> call the routines of the type which gl_window_type is extended from.
> 
> 
> 
> Thanks,
> Chris
> 
> 

-- 
-- Stephe



  reply	other threads:[~2001-11-16 17:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-16 17:07 Help: Tagged Types chris.danx
2001-11-16 17:35 ` Stephen Leake [this message]
2001-11-16 18:02   ` chris.danx
replies disabled

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