Topic: default value specifications


Author: pmoore@hemel.bull.co.uk (Paul Moore)
Date: 12 Dec 90 12:26:46 GMT
Raw View
Has anybody proposed a feature to allow more control over the use of
default values in function specifications?

The area I am trying to address is as follows:-

    funca(int i,int j,int k=1, int l=1)

With this syntax is is possible to invoke funca with both k and l not given,
and with l not given, but it is not possible to invoke funca giving l
but not k.

I can imagine several syntaxes that would allow this to be performed

 funca(1,2,,3);
 funca(1,2,*,3);  // or some other character
 funca(1,2, l=3);

The last one is a more fundamental change as it requires knowledge of the
data names used in the function definition. There are some C implementations
that allow the complete use of parameter association by name rather than
position (taken from ADA I think), a discussion of the usefulness of that
construct should not take place here, although it's not an unreasonable
discussion to have.

My preference is for the first construct as it seems the most natural and
does not involve adding any extra meaning to any tokens, or defining new
tokens.




Author: ahodgson@athena.mit.edu (Antony Hodgson)
Date: 12 Dec 90 15:15:47 GMT
Raw View
In article <1990Dec12.122646.13874@hemel.bull.co.uk> pmoore@hemel.bull.co.uk (Paul Moore) writes:

>[Given:]    funca(int i,int j,int k=1, int l=1)

Could we use a syntax like one of the following to allow us to specify l,
but not k?
>
> funca(1,2,,3);
> funca(1,2,*,3);  // or some other character
> funca(1,2, l=3);
>
>My preference is for the first construct as it seems the most natural and
>does not involve adding any extra meaning to any tokens, or defining new
>tokens.

I would also find this a useful feature, and although I agree that the
first construct is the most "natural", I think I would prefer to use some
character (like _ in Prolog) to call attention to the fact that you are
accepting the default.

Tony Hodgson
ahodgson@hstbme.mit.edu