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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Ada Procedure Parameters That Use the Plus Sign Date: Fri, 12 Jun 2015 10:45:40 +0200 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <871thhpb63.fsf@adaheads.sparre-andersen.dk> References: NNTP-Posting-Host: 109.57.128.104.mobile.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: loke.gir.dk 1434098741 27495 109.57.128.104 (12 Jun 2015 08:45:41 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 12 Jun 2015 08:45:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:PGJZD8woAgRwXp+PH3MXLGrAfKs= Xref: news.eternal-september.org comp.lang.ada:26275 Date: 2015-06-12T10:45:40+02:00 List-Id: NiGHTS writes: > 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. > > 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? Unary plus operator. > 2. What exactly is happening here? A function is called: function "+" (Item : in One_Type) return Maybe_Another_Type; > 3. Is it safe? Should it be avoided? Yes. No. > 4. Is there another way to accomplish this without the use of '+' ? function To_Another_Type (Item : in One_Type) return Another_Type; Gtk_New (Tree, To_Another_Type (Model)); > 5. Where can I find out more about this? In the reference manual, and probably also in Ada text books. Greetings, Jacob -- "It is very easy to get ridiculously confused about the tenses of time travel, but most things can be resolved by a sufficiently large ego."