Re: [sv-cc] DirectC: passing by name, restrictions - summary + solution


Subject: Re: [sv-cc] DirectC: passing by name, restrictions - summary + solution
From: Andrzej Litwiniuk (Andrzej.Litwiniuk@synopsys.com)
Date: Tue Feb 25 2003 - 08:55:18 PST


Team,

The summary seems to be (I'm restating some of previously said things):

1) Calls from C cannot support neither argument passing by name nor default
   values for formal arguments, because it would have required changes to
   the syntax of C.

2) It is highly desirable to have external function calls in SV as similar
   to native function calls as possible, and therefore to support both
   the argument passing by name and the default values for formal arguments
   for external function calls in SV.

   There are no technical difficulties in implementing those features.

3) The main concern seems to be the use model, a convenience and the proness to
   confusions. We seem to have two conflicting guidelines:
   - formal argument names in prototypes customary are optional and meaningless,
   - names of formal arguments shall be unique and consistent if pass by name
     is used, in order to avoid confusion

There is a fundamental difference between native functions and external
functions in SV.
In the case of native functions there is a unique source of complete information
about the function: a function's definition itself. Therefore the prototypes
are only auxiliary and may be restricted less.
In the case of external functions there is no other source of information
then the external declarations.

Let me propose the following solution:

For external functions:

a) formal argument names are optional and generally unrestricted.
   Specifically, multiple declarations of the same function may use different
   names for the same argument or have that argument unnamed, independently for
   each declaration

b) default values for formal arguments are optional yet shall be consistent.
   If a default value for a formal argument is defined then every external
   declaration of the function must define the same default value;
   in other words, either none of multiple declarations of a function
   defines a default value for a particular argument, or all declarations
   of that function define the same value.

c) external function is =unambiguously= defined if for every formal argument
   of that function:
   c-1) either all external declarations of that function define the same name
        or none of them define a name of that formal argument
   c-2) either all external declarations of that function define the same
        default value or none of them define a default value for that formal
        argument

   Note: The above is solely a definition of "unambiguousity". There is no
         requirement that every external function shall be unambiguously
         defined.

d) an external function call may use argument passing by names only if:
   d-1) the function is unambiguously defined
   d-2) for each skipped argument there is a default value defined

I believe that the above rules impose the minimal restrictions upon
external declarations.
Note that there is no restrictions on declarations that don't have default
names and are not used for argument passing by name.

Regards,
Andrzej



This archive was generated by hypermail 2b28 : Tue Feb 25 2003 - 08:56:08 PST