comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: access to subprogram disciminants
Date: 1996/04/24
Date: 1996-04-24T00:00:00+00:00	[thread overview]
Message-ID: <4lm5t3$bqb@news2.delphi.com> (raw)

>I'm not sure what you are trying to accomplish, but the
>above is legal (modulo a few typos, etc.)
  Yes, I tried it again.  I had tried it the first time with
the "object:definer.objects(p'access);" in a main program "procedure"
rather than in a "package" and OS/2 GNAT complained about access level.
(Perils of trying to copy and simplify from actual code to internet post.)
I take it that merely means the outer main procedure has a lifetime
shorter than the packages it uses, so it must be structured to call on
a package to do the actual work.

>: 2) Other than generics or discriminants of records (or tasks),
>: what other ways are there of creating parameterized objects in Ada?
>
>Again, I am not exactly sure what you mean by "parameterized"
>objects.  It might be helpful to understand the ultimate problem

I have existing Ada 83 Windows code using generics in the form:

   procedure main_window_procedure(Message, ...

   package main_window is new Windows.frame_windows(
     width  =>200,
     height =>200,
     title  =>"Cars and Drivers",
     wndproc=>main_window_procedure);

   car_list:main_window.listboxes;
   driver_name_dialog:main_window.dialog_boxes;

   begin

   which_car:=main_window.open(car_list);

etc.

I think of 'main_window' as an object, parameterized by width, height,
title, wndproc, etc.  Though generics have several nice characteristics,
I can't easily make an array of them, for instance, so, now that
'access to subprogram' and 'access all' are available in Ada 95, it may
be reasonable to have instead

   type frame_windows(width, height: integer;
                      title: string_ptr;
                      wndproc: wndproc_ptr) is ...

   main_window:aliased frame_windows(
     width  =>200,
     height =>200,
     title  =>title_string_ptr,
     wndproc=>main_window_procedure'access);

   car_list:Windows.listboxes(main_window'access);
   driver_name_dialog:Windows.dialog_boxes(main_window'access);

   begin

   which_car:=Windows.open(car_list);

(Pardon typos and elisions.  This is typed for posting and is intended
to show the idea, not to be running code.)

That is what I mean by creating a parameterized object.  Unless I'm
missing something, or some clever way of using record tags, Ada 95
provides generics, records with discriminants, and tasks with
discriminants, as ways of declaring such things.  (Discounting
highly limited things like the size of an array as a 'parameter'
of the array)




             reply	other threads:[~1996-04-24  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-24  0:00 tmoran [this message]
1996-04-25  0:00 ` access to subprogram disciminants Tucker Taft
  -- strict thread matches above, loose matches on Subject: below --
1996-04-27  0:00 tmoran
1996-04-26  0:00 tmoran
1996-04-26  0:00 ` Tucker Taft
1996-04-26  0:00 ` Robert I. Eachus
1996-04-23  0:00 tmoran
1996-04-24  0:00 ` Tucker Taft
replies disabled

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