comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Basics : many way to use a Procedure
Date: Fri, 11 Dec 2015 17:00:00 -0700
Date: 2015-12-11T17:00:00-07:00	[thread overview]
Message-ID: <n4fntc$dqb$1@dont-email.me> (raw)
In-Reply-To: <6caaac83-bca4-4b75-a4b3-47189e281c1a@googlegroups.com>

On 12/11/2015 03:19 PM, comicfanzine@gmail.com wrote:
> 
> Ada.Text_IO.Create (
>           File => Log_File,
>           Name => "my_log_file.txt",
>           Mode => Ada.Text_IO.Out_File);
> 
> which is very similar to the prototype :
> 
>  procedure Open
>      (File : in out File_Type;
>       Mode : File_Mode;
>       Name : String;
>       Form : String := "");

This is a procedure declaration. Ada doesn't have prototypes. Also, this is the
declaration for Open, not Create.

This is an example of named parameter associations, often called named notation
for short; the other way is positional notation. They have the form

Formal_Parameter => Actual_Parameter

See ARM 6.4:

http://www.adaic.org/resources/add_content/standards/12rm/html/RM-6-4.html

Named notation is often used for procedure calls. They can make the call easier
to understand, and allow the order of the parameters to differ from those in the
declaration, as in your example.

For function calls, it's usually clearer to use positional notation for the 1st
parameter, IMO:

Image (Some_Value);

rather than

Image (Item => Some_Value);

> Also , is it possible to apply this kind of writing  for this procedure ? =
> 
> procedure Gtk_New
>      (Window   : out Gtk_Window;
>       The_Type : Gtk.Enums.Gtk_Window_Type := Gtk.Enums.Window_Toplevel);

Of course:

Gtk.Something.Gtk_New
   (Window => Msg_Window[, The_Type => Gtk.Enums.Some_Value]);

-- 
Jeff Carter
"I like it when the support group complains that they have
insufficient data on mean time to repair bugs in Ada software."
Robert I. Eachus
91


  reply	other threads:[~2015-12-12  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 22:19 Basics : many way to use a Procedure comicfanzine
2015-12-12  0:00 ` Jeffrey R. Carter [this message]
2015-12-12  3:25 ` comicfanzine
2015-12-12  8:01   ` Niklas Holsti
2015-12-12 10:59   ` mockturtle
2015-12-14 10:52   ` Mark Lorenzen
2015-12-12 10:47 ` Lucretia
2015-12-12 14:41 ` comicfanzine
2015-12-12 17:11   ` Jeffrey R. Carter
2015-12-12 19:28   ` Simon Wright
2015-12-12 19:59     ` comicfanzine
2015-12-12 20:06     ` comicfanzine
2015-12-12 20:31       ` Simon Wright
2015-12-12 21:54         ` comicfanzine
2015-12-12 22:15         ` comicfanzine
2015-12-12 22:33           ` Jeffrey R. Carter
2015-12-13 15:22             ` comicfanzine
2015-12-13 15:29             ` comicfanzine
2015-12-13 15:34             ` comicfanzine
replies disabled

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