Re: [sv-cc] another directC question - defaults for args, passing by name


Subject: Re: [sv-cc] another directC question - defaults for args, passing by name
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Wed Feb 12 2003 - 10:40:16 PST


> From: "Francoise Martinolle" <fm@cadence.com>
>
> Andrzej,
> I am catching up with my sv-cc email and here is the response to your
> questions.
>
> At 07:30 PM 2/11/2003 -0500, Andrzej Litwiniuk wrote:
> > > > Please correct me if I'm wrong.
> > >
> > > You can skip arguments and use named arguments in general in SV, you
> > > just can't mix the two after you use a named binding (I would rather not
> > > mix them at all).
> > >
> > > SV Draft 2 covers this etc in section 10.5.3.
> > >
> > > Kev.
> >
> >Thanks Kevin & Francoise for pointing this!
> >My appologies: I didn't know about those changes,
> >
> >Apparently DirectC needs proofreading against LRM 3.0.
>
> This is why it helps to attend all 3 committees!
>
>
> >I was amazed - I'm kind of digressing now - by the sub-chapter 10.5.
> >It uses the term "subroutine" while everywhere else it is function/task.
>
> I sent an email to Dave Smith and asked him to correct this for consistency
> in the draft.
>
>
> >Then, default values for arguments. Pls. notice the absence of any
> >restrictions!
> >So, I guess, literal aggregates (structs, arrays) are allowed for default
> >values of arguments? And what about default values for arguments passed
> >by reference ('var')?

> >What it would mean to have: 'task foo(var int i = 10);' ?
>
> It does not make much sense.

since it's a reference (not a pointer) it would need to refer to
a value or null -
  
  int glob_i;

  task foo(ref int i = glob_i)

[which reminds me that this syntax sucks since "i = glob_i" would
be different in a non declarative context] or

  task foo(ref int i = null)

- which you might want to be the default.

> >Well, it ain't my problem, sv-bc guys surely will take care of it.
>
> This default argument value and passing by reference was added by the
> extension committee. So I mention this to Dave Smith too. I think also we
> changed the var keyword to
> be ref as of last meeting vote.
>
>
> >Talking about =our= problems, it shouldn't be a big deal to allow
> >the default values for arguments of external functions.
>
> agreed with you, if no actual arguments are passed in the directC call, then
> we use the default provided values.
>
> >It shouldn't be permitted, however, for exported SV functions called from C.
> >(Kevin may comment that it would be a different story had we built the
> >interface
> >upon C++.)
>
> Correct C function calls do not allow to use default argument values in the
> function call.
>
>
> >I see, however, some issues with passing by name.
> >
> >Again, it shouldn't be permitted for exported SV functions called from C.
>
> Correct, neither a mix of named/position when called from C.
>

The use of name binding and defaults (allowed in C++) is syntactic sugar, the
caller always supplies all arguments (in a fixed order).

> ....

Kev



This archive was generated by hypermail 2b28 : Wed Feb 12 2003 - 10:41:24 PST