From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9eaef25f8adbf762 X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: access to subprogram disciminants Date: 1996/04/24 Message-ID: <4lm5t3$bqb@news2.delphi.com>#1/1 X-Deja-AN: 151243371 organization: Delphi Internet Services Corporation newsgroups: comp.lang.ada Date: 1996-04-24T00:00:00+00:00 List-Id: >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)