[sv-bc] Mantis 1602: task/function default inout arguments

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Mon Jul 16 2007 - 01:39:45 PDT
Hi,

Section 13.5.3 in Draft 3a describes task/function default arguments.
Mantis 1602 describes ambiguity with respect to inout defaults.
Many questions and possibilities arose during the discussion of this and
I would like to get the feeling of the committee with respect to the
desired resolution.
See Mantis 1602 for a full discussion of the issues.

Answering the following questions will clarify the desired resolution.

Normally, inout arguments are copy-in at the beginning of execution of
the call and copy-out at the end. So a regular inout argument needs to
be legal as an lvalue (left-hand side of a procedural assignment).

1. Should a default inout argument behave the same as a regular inout
argument? 

That would mean it would have to be a legal lvalue and the value would
be copied out to the default argument at the end of the call.

It would mean also that the following text is not precise: 
"When the subroutine is called, arguments with default values can be
omitted from the call, and the compiler shall insert their corresponding
values." 
That text would work for the copy-in at the beginning, but not for the
copy-out at the end. For the copy-out, the compiler would need to insert
the default expression itself, not its value.

Also, since "The expression is evaluated in the scope containing the
subroutine declaration each time a call using the default is made,"
the copy-out expression would be bound to the declaration scope, not to
the scope of the call.

In the case of a static routine, it would also preserve its value
between calls.


2. Should a default inout argument be treated like an input argument?
(After all, outputs *currently* cannot have defaults.)
2a. Should there be only copy-in at the beginning, but no copy-end at
the end?
2b. Should a default inout argument be allowed to be any legal input
expression, including a constant, and need not be a legal lvalue?
2c. Do you favor only 2a, but not 2b?


3. What about a ref argument default? Does it have to be a (pointer to
a) valid lvalue?


4. Should you be able to leave off an output argument? That presumably
means simply discarding the output value. (Mantis 1600)


5. Should you be able to specify an output default?  If you answer 'yes'
to question 1, then maybe you would favor this as well, with the same
behavior as in question 1, because an inout is a combination of an input
and an output.


6. If you answered 'yes' to question 2 or 4, then what about the formal
argument connected to a defaulted inout or an unconnected output in a
static routine? Should it be treated like any other internal variable of
the routine, retaining its value between calls?


7. Do you favor removing defaults from inout arguments altogether?

8. Do you favor removing defaults from ref arguments altogether?

If there is a clear consensus in a certain direction, then we can write
a proposal for it. Currently, we don't yet know what direction to go in.

Thanks,
Shalom

Shalom Bresticker
Intel Jerusalem LAD DA
+972 2 589-6852
+972 54 721-1033


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Jul 16 01:40:41 2007

This archive was generated by hypermail 2.1.8 : Mon Jul 16 2007 - 01:41:30 PDT