comp.lang.ada
 help / color / mirror / Atom feed
* Basics : many way to use a Procedure
@ 2015-12-11 22:19 comicfanzine
  2015-12-12  0:00 ` Jeffrey R. Carter
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-11 22:19 UTC (permalink / raw)


Hello !

I'm seeing that some people use procedure with the sign " => " .
What is it ? Any documentation about this ? 

A example =

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 := "");

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);


Thanks for your answers :)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-11 22:19 Basics : many way to use a Procedure comicfanzine
@ 2015-12-12  0:00 ` Jeffrey R. Carter
  2015-12-12  3:25 ` comicfanzine
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Jeffrey R. Carter @ 2015-12-12  0:00 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-11 22:19 Basics : many way to use a Procedure comicfanzine
  2015-12-12  0:00 ` Jeffrey R. Carter
@ 2015-12-12  3:25 ` comicfanzine
  2015-12-12  8:01   ` Niklas Holsti
                     ` (2 more replies)
  2015-12-12 10:47 ` Lucretia
  2015-12-12 14:41 ` comicfanzine
  3 siblings, 3 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-12  3:25 UTC (permalink / raw)


Edit : Sorry for the mistake .

I'm trying to understand the A.R.M .
When programming , it's difficult to apply it .

No , in fact , i'm lost... :

actual_parameter_part ::= 
    (parameter_association {, parameter_association})

parameter_association ::= 
   [formal_parameter_selector_name =>] explicit_actual_parameter

explicit_actual_parameter ::= expression | variable_name

------- Each time i code , i'm getting a long list of errors .

I tried to apply the A.R.M with this , without success :

procedure Gtk_New
      (Window   : out Gtk_Window;
       The_Type : Gtk.Enums.Gtk_Window_Type := Gtk.Enums.Window_Toplevel);

And i still don't find a tutorial or code example who explain simply those strange writin forms :(

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  2 siblings, 0 replies; 19+ messages in thread
From: Niklas Holsti @ 2015-12-12  8:01 UTC (permalink / raw)


On 15-12-12 05:25 , comicfanzine@gmail.com wrote:
> ------- Each time i code , i'm getting a long list of errors .

Show your code and the error messages, perhaps we can give better help then.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-11 22:19 Basics : many way to use a Procedure comicfanzine
  2015-12-12  0:00 ` Jeffrey R. Carter
  2015-12-12  3:25 ` comicfanzine
@ 2015-12-12 10:47 ` Lucretia
  2015-12-12 14:41 ` comicfanzine
  3 siblings, 0 replies; 19+ messages in thread
From: Lucretia @ 2015-12-12 10:47 UTC (permalink / raw)


On Friday, 11 December 2015 22:19:55 UTC, comicf...@gmail.com  wrote:
> Hello !
> 
> I'm seeing that some people use procedure with the sign " => " .
> What is it ? Any documentation about this ? 
> 
> A example =
> 
> Ada.Text_IO.Create (
>           File => Log_File,
>           Name => "my_log_file.txt",
>           Mode => Ada.Text_IO.Out_File);

It's called named parameter association. It allows you to change the order of the parameters passed to a function/procedure to one that makes reading easier or just your own preference.

> which is very similar to the prototype :
> 
>  procedure Open
>      (File : in out File_Type;
>       Mode : File_Mode;
>       Name : String;
>       Form : String := "");

For example, given the proper context clauses:

Open (Name => "hello.txt", File => My_File, Mode => In_File);

or you can use it partially, as in:

Open (My_File, Name => "hello.txt", Mode => In_File);

> Also , is it possible to apply this kind of writing  for this procedure ? =

You can apply it to all functions/procedures. 

Luke.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  2 siblings, 0 replies; 19+ messages in thread
From: mockturtle @ 2015-12-12 10:59 UTC (permalink / raw)


On Saturday, December 12, 2015 at 4:25:27 AM UTC+1, comicf...@gmail.com wrote:
> Edit : Sorry for the mistake .
> 
> I'm trying to understand the A.R.M .
> When programming , it's difficult to apply it .
> 
> No , in fact , i'm lost... :

Welcome to the club :-) (although I am not a member of it anymore).

The ARM is written in "computer science legalese," one of the most obscure form of communication after cryptography... :-)  

Seriously, the ARM is not a tutorial, but a standard document and this kind of prose is a consequence of that.  I know that the ARM is not an easy reading when you are a beginner, but you'll get used to it and then it will be a fundamental and precious reference for you (personal experience).

What the excerpt that you posted say is that an actual_parameter_part is a sequence of one or more parameter_association separated by comma and included between parenthesis.  Every parameter_association can be both a value (called explicit_actual_parameter in the grammara) or a string of type "name => value" (where name is an identifier and its called formal_parameter_association_name in the grammar).

If you post your code and the error message, we can be more precise.

Riccardo


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-11 22:19 Basics : many way to use a Procedure comicfanzine
                   ` (2 preceding siblings ...)
  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
  3 siblings, 2 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-12 14:41 UTC (permalink / raw)


Thanks for your answers everybody :)

But , i still don't know where this sign come from : " => " . Any information or A.R.M documentation about it ??

Also , how to use this ?? =

actual_parameter_part ::= 
    (parameter_association {, parameter_association})

And this ?? =

parameter_association ::= 
   [formal_parameter_selector_name =>] explicit_actual_parameter


For the moment , i figured out how to use this ( at least :) ) =

procedure_call_statement ::= 
    procedure_name;
  | procedure_prefix actual_parameter_part;

I used it like this :

    WITH Gtk.Main ;          USE Gtk.Main ;
    WITH Gtk.Window ;        USE Gtk.Window ;
    WITH Gtk.Enums ;         USE Gtk.Enums ;

    Procedure procedure_gtkada is
    
        win : Gtk_window ;
     
    begin
    
     Init ; 
     
	Gtk_New(Window => Win, 
		The_Type => Gtk.Enums.Window_Toplevel); 
			       
-- procedure Gtk_New
   --  (Window   : out Gtk_Window;
   --   The_Type : Gtk.Enums.Gtk_Window_Type := Gtk.Enums.Window_Toplevel);
     
     Show_all(win) ; 
     
       Main ; 
	
end procedure_gtkada;

-- Compile with : gnatmake procedure_gtkada `gtkada-config`
-- Of course you need the libgtkada .








^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-12 14:41 ` comicfanzine
@ 2015-12-12 17:11   ` Jeffrey R. Carter
  2015-12-12 19:28   ` Simon Wright
  1 sibling, 0 replies; 19+ messages in thread
From: Jeffrey R. Carter @ 2015-12-12 17:11 UTC (permalink / raw)


On 12/12/2015 07:41 AM, comicfanzine@gmail.com wrote:
> 
> But , i still don't know where this sign come from : " => " . Any information or A.R.M documentation about it ??

This is a compound delimiter, known in Ada as an arrow (ARM 2.2). It's used to
associate something on the left with the thing on the right, as in
subprogram-call parameter lists, generic instantiations, and aggregates.

> 	Gtk_New(Window => Win, 
> 		The_Type => Gtk.Enums.Window_Toplevel); 

It appears that you understand this.

-- 
Jeff Carter
"English bed-wetting types."
Monty Python & the Holy Grail
15

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  1 sibling, 2 replies; 19+ messages in thread
From: Simon Wright @ 2015-12-12 19:28 UTC (permalink / raw)


comicfanzine@gmail.com writes:

> But , i still don't know where this sign come from : " => " . Any
> information or A.R.M documentation about it ??
>
> Also , how to use this ?? =
>
> actual_parameter_part ::= 
>     (parameter_association {, parameter_association})
>
> And this ?? =
>
> parameter_association ::= 
>    [formal_parameter_selector_name =>] explicit_actual_parameter

ARM 6.4(13)?

http://www.ada-auth.org/standards/12rm/html/RM-6-4.html#p13

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-12 19:28   ` Simon Wright
@ 2015-12-12 19:59     ` comicfanzine
  2015-12-12 20:06     ` comicfanzine
  1 sibling, 0 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-12 19:59 UTC (permalink / raw)


Le samedi 12 décembre 2015 19:28:03 UTC, Simon Wright a écrit :
> comicfanzine@gmail.com writes:
> 
> > But , i still don't know where this sign come from : " => " . Any
> > information or A.R.M documentation about it ??
> >
> > Also , how to use this ?? =
> >
> > actual_parameter_part ::= 
> >     (parameter_association {, parameter_association})
> >
> > And this ?? =
> >
> > parameter_association ::= 
> >    [formal_parameter_selector_name =>] explicit_actual_parameter
> 
> ARM 6.4(13)?
> 
> http://www.ada-auth.org/standards/12rm/html/RM-6-4.html#p13

The Examples form does not match this one =

actual_parameter_part ::= 
    (parameter_association {, parameter_association})

parameter_association ::= 
   [formal_parameter_selector_name =>] explicit_actual_parameter

explicit_actual_parameter ::= expression | variable_name


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  1 sibling, 1 reply; 19+ messages in thread
From: comicfanzine @ 2015-12-12 20:06 UTC (permalink / raw)


>> ARM 6.4(13)?
> 
> http://www.ada-auth.org/standards/12rm/html/RM-6-4.html#p13

The form is different =

actual_parameter_part ::= 
    (parameter_association {, parameter_association})

parameter_association ::= 
   [formal_parameter_selector_name =>] explicit_actual_parameter

explicit_actual_parameter ::= expression | variable_name

Still, i don't know how to use those forms .


Also i don't find in the A.R.M , a description of the possibillities for using = 

compound delimiters " => "


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  0 siblings, 2 replies; 19+ messages in thread
From: Simon Wright @ 2015-12-12 20:31 UTC (permalink / raw)


comicfanzine@gmail.com writes:

>>> ARM 6.4(13)?
>> 
>> http://www.ada-auth.org/standards/12rm/html/RM-6-4.html#p13
>
> The form is different =
>
> actual_parameter_part ::= 
>     (parameter_association {, parameter_association})
>
> parameter_association ::= 
>    [formal_parameter_selector_name =>] explicit_actual_parameter
>
> explicit_actual_parameter ::= expression | variable_name
>
> Still, i don't know how to use those forms .

In what way does the 4th example,

  Print_Header(128, Header => Title, Center => True);

not match those forms?

Perhaps you'd better post an example of what you think the ARM's syntax
is telling you to write.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-12 20:31       ` Simon Wright
@ 2015-12-12 21:54         ` comicfanzine
  2015-12-12 22:15         ` comicfanzine
  1 sibling, 0 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-12 21:54 UTC (permalink / raw)


> In what way does the 4th example,
> 
>   Print_Header(128, Header => Title, Center => True);
> 
> not match those forms?
> 
> Perhaps you'd better post an example of what you think the ARM's syntax
> is telling you to write.

the 4th example look a little like =

    [formal_parameter_selector_name =>] explicit_actual_parameter

but, there is no "[]" in the 4th example .

Also the 4th example doesn't look like this other form , there is no "{}" =

 actual_parameter_part ::= 
    (parameter_association {, parameter_association})

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  1 sibling, 1 reply; 19+ messages in thread
From: comicfanzine @ 2015-12-12 22:15 UTC (permalink / raw)


> > In what way does the 4th example,
> > 
> >   Print_Header(128, Header => Title, Center => True);
> > 
> > not match those forms?
> > 
> > Perhaps you'd better post an example of what you think the ARM's syntax
> > is telling you to write.
 
 the 4th example look a little like =
 
     [formal_parameter_selector_name =>] explicit_actual_parameter
 
 but, there is no "[]" in the 4th example .
 
 Also the 4th example doesn't look like this other form , there is no "{}" =
 
  actual_parameter_part ::= 
     (parameter_association {, parameter_association})

Also , what this next form means ? What means the delimiter " | " ?

explicit_actual_parameter ::= expression | variable_name

At the end , i don't find in the A.R.M , a description of the possibillities for using = compound delimiters " => " 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  2015-12-12 22:15         ` comicfanzine
@ 2015-12-12 22:33           ` Jeffrey R. Carter
  2015-12-13 15:22             ` comicfanzine
                               ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Jeffrey R. Carter @ 2015-12-12 22:33 UTC (permalink / raw)


On 12/12/2015 03:15 PM, comicfanzine@gmail.com wrote:
>>> In what way does the 4th example,
>>>
>>>   Print_Header(128, Header => Title, Center => True);
>>>
>>> not match those forms?
>>>
>>> Perhaps you'd better post an example of what you think the ARM's syntax
>>> is telling you to write.
>  
>  the 4th example look a little like =
>  
>      [formal_parameter_selector_name =>] explicit_actual_parameter
>  
>  but, there is no "[]" in the 4th example .
>  
>  Also the 4th example doesn't look like this other form , there is no "{}" =
>  
>   actual_parameter_part ::= 
>      (parameter_association {, parameter_association})
> 
> Also , what this next form means ? What means the delimiter " | " ?
> 
> explicit_actual_parameter ::= expression | variable_name

The BNF used to define the syntax is given in ARM 1.1.4.

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

You need to be familiar with the notation before you read the rest of the ARM.

Brackets [] surround optional items; braces {} surround items that may appear
zero or more times; the vertical bar | separates alternatives. So

[formal_parameter_selector_name =>] explicit_actual_parameter

means "formal_parameter_selector_name =>" is optional; the parameter 128 in the
example has that part omitted.

actual_parameter_part ::=
   (parameter_association {, parameter_association})

means there's at least 1 parameter_association in an actual_parameter_part, and
if there are more than 1, the others are all preceded by a comma,

explicit_actual_parameter ::= expression | variable_name

means an explicit_actual_parameter is either an expression or a variable_name.

-- 
Jeff Carter
"English bed-wetting types."
Monty Python & the Holy Grail
15

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  2 siblings, 0 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-13 15:22 UTC (permalink / raw)


@Jeff Carter= Thanks , i understand all now .


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  2 siblings, 0 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-13 15:29 UTC (permalink / raw)


@Jeff Carter= Thanks , i understand all now . 

Also , i finally found clear examples for using " => "

https://en.wikibooks.org/wiki/Ada_Programming/Delimiters/arrow#Ada_Reference_Manual


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  2 siblings, 0 replies; 19+ messages in thread
From: comicfanzine @ 2015-12-13 15:34 UTC (permalink / raw)


@Jeff Carter= Thanks , i understand all now .

Also , i finally found clear examples for using " => " 

https://en.wikibooks.org/wiki/Ada_Programming/Delimiters/arrow#Contexts

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Basics : many way to use a Procedure
  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
  2 siblings, 0 replies; 19+ messages in thread
From: Mark Lorenzen @ 2015-12-14 10:52 UTC (permalink / raw)


On Saturday, December 12, 2015 at 4:25:27 AM UTC+1, comicf...@gmail.com wrote:
> Edit : Sorry for the mistake .
> 
> I'm trying to understand the A.R.M .
> When programming , it's difficult to apply it .
> 
> No , in fact , i'm lost... :

I recommend that you use a textbook instead of the ARM.

Regards,

Mark L

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-12-14 10:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-11 22:19 Basics : many way to use a Procedure comicfanzine
2015-12-12  0:00 ` Jeffrey R. Carter
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

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