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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Procedure Parameters That Use the Plus Sign Date: Fri, 12 Jun 2015 10:00:47 +0200 Organization: cbb software GmbH Message-ID: <6p8ml2yn7z6m.168scgt6xcuc2.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: enOx0b+nfqkc2k+TNpOejg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.giganews.com comp.lang.ada:193581 Date: 2015-06-12T10:00:47+02:00 List-Id: On Thu, 11 Jun 2015 10:24:45 -0700 (PDT), NiGHTS wrote: > I recently stumbled across some Ada code that appends a plus sign in front > of a parameter name of a function or procedure call. From the context it > seems like it is doing a forced cast between two incompatible types. Compatible types actually. > Here is one example I found in the AdaGtk demo create_tree_view.adb line 243: > > Gtk_New (Tree, +Model); > > My questions are: > > 1. What is this called? Is there a name for this? In this case it is a downcast, I believe. > 2. What exactly is happening here? A concrete tree model is converted to the model interface. There is no physical conversion, of course, just a reference object is converted to another reference object. Thus from the language POV it is a conversion, from the GTK's POV it is not. > 3. Is it safe? Should it be avoided? It is safe, though a quite lot irritating. > 4. Is there another way to accomplish this without the use of '+' ? In this concrete case there is no other way (I mean without an explicit call) because Ada lacks the sort of MI/subtyping which would be required for this. In GtkAda, I think (too lazy to look), you could also use To_Interface instead: Gtk_New (Tree, To_Interface (Model)); which is just same, but looks better and cleaner. > 5. Where can I find out more about this? Ada reference manual, GtkAda reference? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de