From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: GtkAda : Trying to derive a widget Date: Fri, 9 Apr 2021 08:12:19 +0200 Organization: Adalog Message-ID: References: <606f5938$0$27421$426a74cc@news.free.fr> <606fe610$0$3717$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 9 Apr 2021 06:12:20 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="7f930d4ebb32644f36580e6865b08889"; logging-data="15292"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1jzY27nkko7fSebDeG86H" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 Cancel-Lock: sha1:XamwYnBomHdgblaytQW3j7CCNBc= In-Reply-To: <606fe610$0$3717$426a74cc@news.free.fr> Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:61763 List-Id: 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. 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. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr