comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Ada Procedure Parameters That Use the Plus Sign
Date: Fri, 12 Jun 2015 10:45:40 +0200
Date: 2015-06-12T10:45:40+02:00	[thread overview]
Message-ID: <871thhpb63.fsf@adaheads.sparre-andersen.dk> (raw)
In-Reply-To: b3779aef-43d6-4186-8de5-814346f2ab0e@googlegroups.com

NiGHTS <nights@unku.us> 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."

  parent reply	other threads:[~2015-06-12  8:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 17:24 Ada Procedure Parameters That Use the Plus Sign NiGHTS
2015-06-11 17:36 ` David Botton
2015-06-11 18:21   ` NiGHTS
2015-06-11 18:52     ` David Botton
2015-06-12  8:00 ` Dmitry A. Kazakov
2015-06-12  8:45 ` Jacob Sparre Andersen [this message]
2015-06-12 15:19 ` NiGHTS
replies disabled

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