comp.lang.ada
 help / color / mirror / Atom feed
* Order of execution of subprogram parameters
@ 2011-03-19 17:10 Syntax Issues
  2011-03-19 18:58 ` Jeffrey Carter
  0 siblings, 1 reply; 3+ messages in thread
From: Syntax Issues @ 2011-03-19 17:10 UTC (permalink / raw)


Across ada compilers what is the order of execution for subprogram
parameters? Is it left-to-right, right-to-left, and does it matter if
I use labels out of order?

Example:
...
type Record_Joint
	is record
		Name   : String(1..64);
		Flags  : Integer_1_Unsigned;
		Parent : Integer_4_Signed;
		Start  : Integer_4_Signed;
	end record;
package Container_Record_Joint
	is new Ada.Containers.Indefinite_Vectors
	(Integer_4_Unsigned, Record_Joint);
...
Animation    : Record_Md5_Animation;
...
Animation.Joints.Append(
	(Name   => Remove_Quotes(Next_String(File, Current_Line)),
	 Parent => Next_Integer_4_Signed(File, Current_Line),
	 Flags  => Next_Integer_1_Unsigned(File, Current_Line),
	 Start  => Next_Integer_4_Signed(File, Current_Line));
...
function Next_X
	(File : in out File_Type;
	 Line : in out String)
	return X;



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

* Re: Order of execution of subprogram parameters
  2011-03-19 17:10 Order of execution of subprogram parameters Syntax Issues
@ 2011-03-19 18:58 ` Jeffrey Carter
  2011-03-19 19:51   ` Syntax Issues
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey Carter @ 2011-03-19 18:58 UTC (permalink / raw)


On 03/19/2011 10:10 AM, Syntax Issues wrote:
> Across ada compilers what is the order of execution for subprogram
> parameters? Is it left-to-right, right-to-left, and does it matter if
> I use labels out of order?

ARM 6.4 says,

"For the execution of a subprogram call, the name or prefix of the call is 
evaluated, and each parameter_association is evaluated (see 6.4.1). If a 
default_expression is used, an implicit parameter_association is assumed for 
this rule. These evaluations are done in an arbitrary order."

> Animation.Joints.Append(
> 	(Name   =>  Remove_Quotes(Next_String(File, Current_Line)),
> 	 Parent =>  Next_Integer_4_Signed(File, Current_Line),
> 	 Flags  =>  Next_Integer_1_Unsigned(File, Current_Line),
> 	 Start  =>  Next_Integer_4_Signed(File, Current_Line));

However, what you have here is not evaluation of subprogram parameters but 
evaluation of aggregate components. The answer, from ARM 4.3, is the same:

"For the evaluation of an aggregate, an anonymous object is created and values 
for the components or ancestor part are obtained (as described in the subsequent 
subclause for each kind of the aggregate) and assigned into the corresponding 
components or ancestor part of the anonymous object. Obtaining the values and 
the assignments occur in an arbitrary order."

-- 
Jeff Carter
"C++: The power, elegance and simplicity of a hand grenade."
Ole-Hjalmar Kristensen
90



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

* Re: Order of execution of subprogram parameters
  2011-03-19 18:58 ` Jeffrey Carter
@ 2011-03-19 19:51   ` Syntax Issues
  0 siblings, 0 replies; 3+ messages in thread
From: Syntax Issues @ 2011-03-19 19:51 UTC (permalink / raw)


On Mar 19, 2:58 pm, Jeffrey Carter
<spam.jrcarter....@spam.not.acm.org> wrote:
> On 03/19/2011 10:10 AM, Syntax Issues wrote:
>
> > Across ada compilers what is the order of execution for subprogram
> > parameters? Is it left-to-right, right-to-left, and does it matter if
> > I use labels out of order?
>
> ARM 6.4 says,
>
> "For the execution of a subprogram call, the name or prefix of the call is
> evaluated, and each parameter_association is evaluated (see 6.4.1). If a
> default_expression is used, an implicit parameter_association is assumed for
> this rule. These evaluations are done in an arbitrary order."
>
> > Animation.Joints.Append(
> >    (Name   =>  Remove_Quotes(Next_String(File, Current_Line)),
> >     Parent =>  Next_Integer_4_Signed(File, Current_Line),
> >     Flags  =>  Next_Integer_1_Unsigned(File, Current_Line),
> >     Start  =>  Next_Integer_4_Signed(File, Current_Line));
>
> However, what you have here is not evaluation of subprogram parameters but
> evaluation of aggregate components. The answer, from ARM 4.3, is the same:
>
> "For the evaluation of an aggregate, an anonymous object is created and values
> for the components or ancestor part are obtained (as described in the subsequent
> subclause for each kind of the aggregate) and assigned into the corresponding
> components or ancestor part of the anonymous object. Obtaining the values and
> the assignments occur in an arbitrary order."
>
> --
> Jeff Carter
> "C++: The power, elegance and simplicity of a hand grenade."
> Ole-Hjalmar Kristensen
> 90

Great, thanks for the reply.

I'll make sure to better job searching the ARM before I post questions
like this next time.



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

end of thread, other threads:[~2011-03-19 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-19 17:10 Order of execution of subprogram parameters Syntax Issues
2011-03-19 18:58 ` Jeffrey Carter
2011-03-19 19:51   ` Syntax Issues

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