From: DrPi <314@drpi.fr>
Subject: Re: GtkAda : Trying to derive a widget
Date: Fri, 9 Apr 2021 13:32:03 +0200 [thread overview]
Message-ID: <60703b35$0$3265$426a74cc@news.free.fr> (raw)
In-Reply-To: <s4or84$ets$1@dont-email.me>
Le 09/04/2021 à 08:12, J-P. Rosen a écrit :
> Le 09/04/2021 à 07:28, DrPi a écrit :
>>> Without "use" Initialize is unambiguous.
>>>
>> That makes sense.
>> However, I don't understand why there is ambiguity when using "use".
>> Debug_Panel (the type) is of type Debug_Panel_Record, so Initialize
>> should resolve to the one using this type. Well, I guess I'm wrong.
> No, the type is "access Debug_Panel_Record'Class", and the other
> initialize is for "access Gtk_Scrolled_Window_Record'Class", which
> covers the other one.
>
What I mean is that one "Initialize" procedure has a parameter of type
"access Debug_Panel_Record'Class" and the other of type "access
Gtk_Scrolled_Window_Record'Class".
The call to "Initialize" is made with a "Debug_Panel" type which is an
access to "Debug_Panel_Record'Class" not " an access to
"Gtk_Scrolled_Window_Record'Class".
So, why is there an ambiguity here ?
> Remember that a class wide type ('Class) is a different type that covers
> all descendants.
>
>>> P.S. When you create new widget it is better to use a more general
>>> ancestor hiding insufficient details, e.g.
>>>
>>> type Debug_Panel_Record is
>>> new Gtk.Widget.Gtk_Widget_Record with private;
>>> ...
>>> private
>>> type Debug_Panel_Record is
>>> new Gtk.Scrolled_Window.Gtk_Scrolled_Window_Record with
>>> record
>>> ...
>>> end record;
>>
>> I'm surprized this is possible to write such a thing in Ada.
>> What does the compiler do with this ?
>> There is no problem, since
> Gtk.Scrolled_Window.Gtk_Scrolled_Window_Record is a descendant of
> Gtk.Widget.Gtk_Widget_Record. There is no lie: a Debug_Panel_Record IS A
> Gtk_Widget_Record. The private view has more information: it actually IS
> A Gtk_Scrolled_Window_Record, but the extra properties are not
> accessible outside from the package body.
>
Ok. That's interesting.
One more thing learned today :)
next prev parent reply other threads:[~2021-04-09 11:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 19:27 GtkAda : Trying to derive a widget DrPi
2021-04-08 22:27 ` Dmitry A. Kazakov
2021-04-09 5:28 ` DrPi
2021-04-09 6:12 ` J-P. Rosen
2021-04-09 11:32 ` DrPi [this message]
2021-04-09 6:18 ` Dmitry A. Kazakov
2021-04-09 11:42 ` DrPi
2021-04-09 12:23 ` Dmitry A. Kazakov
2021-04-09 13:37 ` DrPi
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox