function argument 'shorthand'

Bill Baxter Bill_member at pathlink.com
Thu May 25 00:31:09 PDT 2006


In article <e53f58$15dc$1 at digitaldaemon.com>, Bill Baxter says...
>
>In article <e4tv46$2007$1 at digitaldaemon.com>, Dave says...
>>
>>Walter Bright wrote:
>>> It has grammatical ambiguities. Consider:
>>> 
>>> int foo(int x, y);
>>> 
>>> Is the second a declaration of y of type int, or is it a parameter of 
>>> type y?
>>
>So what about a semi colon or colon or something instead of the comma?
>
>int foo(int x ; y, float z);
>int foo(int x : y : z);

Or even a space for that matter:

int foo(int x y z, real z);

But when you say there's a grammatical ambiguity, can there actually be
variables with the same names as types?  Isn't that against the rules?  So it's
just a low level syntactical ambiguity you're talking about, right?  At the time
you see the ', real' there's ambiguity but only until you check if 'real' is a
type or not.

In other words 
int foo(int x, real) 
has to be one int arg, one real arg, and not two int args, one named 'x', the
other named 'real'.  Right?


Bill



More information about the Digitalmars-d mailing list