comp.lang.ada
 help / color / mirror / Atom feed
* Help: Tagged Types
@ 2001-11-16 17:07 chris.danx
  2001-11-16 17:35 ` Stephen Leake
  0 siblings, 1 reply; 3+ messages in thread
From: chris.danx @ 2001-11-16 17:07 UTC (permalink / raw)


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?

-- 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





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

* Re: Help: Tagged Types
  2001-11-16 17:07 Help: Tagged Types chris.danx
@ 2001-11-16 17:35 ` Stephen Leake
  2001-11-16 18:02   ` chris.danx
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Leake @ 2001-11-16 17:35 UTC (permalink / raw)


"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



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

* Re: Help: Tagged Types
  2001-11-16 17:35 ` Stephen Leake
@ 2001-11-16 18:02   ` chris.danx
  0 siblings, 0 replies; 3+ messages in thread
From: chris.danx @ 2001-11-16 18:02 UTC (permalink / raw)


> > 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));

Ok.


> 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.


There were two options:  override create proper or the event on_create.  The
reason for using create was simple, I forgot that on_create could be used
for this.  I'm going to use on_create instead, it's simpler and closer to
what I intend.


Thanks,
Chris




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

end of thread, other threads:[~2001-11-16 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-16 17:07 Help: Tagged Types chris.danx
2001-11-16 17:35 ` Stephen Leake
2001-11-16 18:02   ` chris.danx

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