comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Properties
Date: Fri, 3 Dec 2010 15:14:09 -0600
Date: 2010-12-03T15:14:09-06:00	[thread overview]
Message-ID: <idbmj3$328$1@munin.nbi.dk> (raw)
In-Reply-To: 75475874-cd6c-4e75-8a2f-7675ecf0864a@f20g2000vbc.googlegroups.com

"Shark8" <onewingedshark@gmail.com> wrote in message 
news:75475874-cd6c-4e75-8a2f-7675ecf0864a@f20g2000vbc.googlegroups.com...
...
>It is somewhat irritating that you cannot initialize element to
>GUI_Base'Class directly.

You can do this with the Ada containers.

>Attempting the following
>   Package GUI_Vector is New Ada.Containers.Vectors
>( Element_Type => GUI_Base'Class, Index_Type => Positive );
>yields
>instantiation error at a-convec.ads:321
>"unconstrained element type in array declaration actual for
>"Element_Type" must be a definite subtype"

Right, but you are using the wrong container for this. Try the indefinite 
containers (designed specifically for this purpose):

Package GUI_Vector is New Ada.Containers.Indefinite_Vectors
   ( Element_Type => GUI_Base'Class, Index_Type => Positive );

This will work fine.

                              Randy.



What's wrong with say initializing Ada.Containers.Vector with Positive
=> Index and Element => Access_GUI_Base_Class*?

*Type Access_GUI_Base_Class is Access GUI_Base'Class;

It would be nice to throw a "Not null" in because storing a 'pointer'
to "not an object" is pretty dumb... but that gives this error-set:
warning: in instantiation at a-convec.adb:1196
warning: (Ada 2005) null-excluding objects must be initialized
warning: "Constraint_Error" will be raised at run time
warning: in instantiation at a-convec.adb:1209
warning: (Ada 2005) null-excluding objects must be initialized
warning: "Constraint_Error" will be raised at run time

It's almost as if it's saying that we couldn't ever use the container
exclusively like this:

Vector : GUI_Vector.Vector:= GUI_Vector.Empty_Vector;
Component_1 : Aliased GUI_Base'Class:= Make_Component( ... );
--...
Component_n : Aliased GUI_Base'Class:= Make_Component( ... );
begin
 Vector.Add( Component_1'Access );
--...
 Vector.Add( Component_n'Access );
--the work
end;

>This raises another question. Ada
> does not support abstract access types. You want a reference to the widget
> be a fat pointer transparent to all widget operations with automatic
> collection of widget objects. This almost works in Ada, but it is 
> extremely
> boring to do.

[snip]
> The bottom line, interfaces must be removed from Ada.
> Instead of that an interface must be made inheritable
> from any concrete type. This is the same idea as with
> abstract record, array etc types.

Wouldn't this be alleviated by two things:
Allowing INTERFACE [keyword] objects to have fields (properties as
I've described, or somesuch)?
Allowing objects some sort of self/this/me attribute where the result
is a Not Null Access to its classwide-type*? (Or am I misunderstanding
what you mean by the need for "a fat pointer transparent to all widget
operations"?)

*Or is this the equivalent of requiring all such variables to be
Aliased?

>
> type Widget_Handle is private Widget; -- Like the widget, but isn't
> private
> type Widget_Handle is new Ada.Limited_Controlled with record
> Ptr : access Widget;
> end record;
>
> For access types there must be delegation support, which should eliminate
> need in wrappers. There are other issues as well, like that "access 
> Widget"
> is purposely not "access Widget'Class."
>
> > Finally, I've been quite impressed with Delphi's Visual Component
> > Library (VCL).
>
> That's interesting, because we are using the VCL quite heavily. One of our
> customers explicitly ordered that. Now, my impression is opposite to 
> yours:
> it is safer, *quicker*, cleaner, an far more maintainable to develop GUI 
> in
> *raw* Windows API than in VCL. As a bonus, you can get rid of that awful
> Borland C++, use VC++ or gcc instead.

Oh, right, the VCL *WAS* ported-over-to/interfaced-with Borland's C
Builder. I'm utterly unfamiliar with that incarnation of the VCL as my
experience with it has been on the Delphi (Object Pascal) side.

But the problem is that wrapping the API calls, and management of the
returned references, in objects yields something similar-in-structure
to the VCL, no?

I'm not saying that things couldn't have been done better; they could
have. But for being a useful object-oriented GUI library tied to a
singular API (Windows) I think it's done pretty well.

The idea we've been kicking around about a truly portable GUI library
with attention to type-safety and [hopefully] prevention of Bad Things
(insofar as they can be prevented, thus your desire for a statically-
checked GUI library) is an order of magnitude more complex. -- Though
I myself would like to see just such a portable GUI library done in
Ada.

>
> > Microsoft's MFC and Java's JFC seem to have been
> > 'inspired' [or copied] from the VCL, but neither presents itself as
> > uniform & usable/mature [if you will] as the VCL.
>
> We dropped MFC long ago and never returned to it. We didn't use JFC, so I 
> cannot say anything about it.

Imagine the VCL, then take away all the inherited handling of events
and make them all purely java-interfaces (so in order to handle events
you have to create some class which implements the interface; this is
usually cone in-line/via-anonymous-class), and you basically have
something similar to the JFC. 





  reply	other threads:[~2010-12-03 21:14 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-28  3:21 Properties Shark8
2010-11-28  8:15 ` Properties Dmitry A. Kazakov
2010-11-28 19:43   ` Properties Shark8
2010-11-29  8:34     ` Properties Dmitry A. Kazakov
2010-12-01 18:15       ` Properties Shark8
2010-11-28 12:37 ` Properties Georg Bauhaus
2010-11-28 21:22   ` Properties Shark8
2010-11-29 16:54     ` Properties Georg Bauhaus
2010-12-01 19:52   ` Properties Martin Krischik
2010-12-01 23:24     ` Properties Georg Bauhaus
2010-12-05 16:15       ` (placepo) Properties Martin Krischik
2010-12-06 23:24         ` Shark8
2010-12-01 23:31     ` Properties Georg Bauhaus
2010-11-30  1:49 ` Properties Randy Brukardt
2010-11-30 16:58   ` Properties Charmed Snark
2010-11-30 17:22     ` Properties Dmitry A. Kazakov
2010-11-30 20:27       ` Properties Warren
2010-12-01  8:39         ` Properties Dmitry A. Kazakov
2010-12-01 15:21           ` Properties Warren
2010-12-01 15:59             ` Properties Dmitry A. Kazakov
2010-12-01 16:20               ` Properties Warren
2010-12-01 18:22                 ` Properties Dmitry A. Kazakov
2010-12-01 19:36                   ` Properties Shark8
2010-12-01 21:13                     ` Properties Dmitry A. Kazakov
2010-12-01 21:35                   ` Properties Maciej Sobczak
2010-12-01 21:45                     ` Properties Dmitry A. Kazakov
2010-12-02  9:57                       ` Properties Maciej Sobczak
2010-12-02 10:26                         ` Properties Dmitry A. Kazakov
2010-12-02 15:25                           ` Properties Maciej Sobczak
2010-12-02 15:46                             ` Properties Dmitry A. Kazakov
2010-12-02 21:11                               ` Properties Maciej Sobczak
2010-12-02 22:19                                 ` Properties Dmitry A. Kazakov
2010-12-03  4:43                                 ` Properties Randy Brukardt
2010-12-03 13:53                                   ` Properties Maciej Sobczak
2010-12-03 21:32                                     ` Properties Randy Brukardt
2010-12-04 22:13                                       ` Properties Maciej Sobczak
2010-12-06 23:30                                         ` Properties Shark8
2010-12-06 23:33                                         ` Properties Randy Brukardt
2010-12-04 17:43                           ` Properties Simon Wright
2010-12-04 20:48                             ` Properties Dmitry A. Kazakov
2010-12-04 22:27                               ` Properties Simon Wright
2010-12-04 22:31                                 ` Properties Vinzent Hoefler
2010-12-03  4:24                         ` Properties Randy Brukardt
2010-12-03  5:00                         ` Properties Shark8
2010-12-03 21:10                           ` Properties Randy Brukardt
2010-12-03 23:34                           ` Properties Jeffrey Carter
2010-12-06  6:02                             ` Properties Brad Moore
2010-12-06 23:25                               ` Properties Shark8
2010-12-01 19:48                 ` Properties Randy Brukardt
2010-12-01 21:10                   ` Properties Warren
2010-12-02  0:03                     ` Properties Shark8
2010-12-02 16:45                       ` Properties Warren
2010-12-02 17:32                         ` Properties Dmitry A. Kazakov
2010-12-02 20:45                           ` Properties Warren
2010-12-02 21:17                             ` Properties Adam Beneschan
2010-12-02 21:40                               ` Properties Warren
2010-12-03  3:34                             ` Properties Shark8
2010-12-03  8:16                               ` Properties Thomas Løcke
2010-12-02 20:52                           ` Properties Pascal Obry
2010-12-02 19:46                         ` Properties Adam Beneschan
2010-12-02 20:38                           ` Properties Warren
2010-12-02 21:39                             ` Properties Jeffrey Carter
2010-12-02 21:55                               ` Properties Warren
2010-12-03  9:33                               ` Properties Anonymous
2010-12-03  3:47                           ` Properties Shark8
2010-12-03  0:09                         ` Properties Robert A Duff
2010-12-03 15:49                           ` Properties Warren
2010-12-03 20:07                             ` Properties Shark8
2010-12-06 21:01                               ` Properties Warren
2010-12-06 23:22                                 ` Properties Shark8
2010-12-07 14:37                                   ` Properties Warren
2010-12-08 21:13                                   ` Properties Simon Wright
2010-12-09  1:21                                     ` Properties Shark8
2010-12-06 23:43                                 ` Properties Randy Brukardt
2010-12-07  0:56                                   ` Properties Jeffrey Carter
2010-12-07 11:23                                   ` Properties Maciej Sobczak
2010-12-07 11:51                                     ` Properties Georg Bauhaus
2010-12-07 15:35                                       ` Properties Maciej Sobczak
2010-12-07 17:02                                         ` Properties Georg Bauhaus
2010-12-07 14:39                                   ` Properties Warren
2010-12-03 15:40                         ` Properties Warren
2010-12-03 19:56                           ` Properties Shark8
2010-12-03 20:12                             ` Properties Warren
2010-12-03  5:53               ` Properties Shark8
2010-12-03  9:05                 ` Properties Dmitry A. Kazakov
2010-12-03 19:52                   ` Properties Shark8
2010-12-03 21:14                     ` Randy Brukardt [this message]
2010-12-04  5:35                       ` Properties Shark8
2010-12-04 14:23                         ` Properties Peter C. Chapin
2010-12-04 18:53                           ` Properties Shark8
2010-12-13 15:10                       ` Properties Brian Drummond
2010-12-03 22:38                     ` Properties Dmitry A. Kazakov
2010-12-04  3:12                       ` Properties Shark8
2010-12-04 13:19                     ` Properties Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2010-12-04 19:53 Properties Shark8
2010-12-04 23:27 ` Properties Thomas Løcke
replies disabled

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