[Nickle]Scoping rules for declarations

Keith Packard nickle@keithp.com
Wed, 30 Jan 2002 21:24:01 -0800


Around 12 o'clock on Jan 30, Barton C Massey wrote:

>   1) AFAIK bar_expression cannot even refer to bar as things
>      are currently implemented.  This is arguably just a
>      bug, and should be fixed.

I've changed the grammar to permit this case.  The intent is that the 
language operate uniformly left to right, and this was indeed a violation 
of that.  The semantics of initializers should be clarified to assert that

	<type> foo = <expr>;

is exactly identical to

	((<type> foo), foo = <expr>)

>  Clearly, there are ugly warts here.  I'll kick around the
>  `function' syntax with Keith and we'll see what we can
>  figure out.

If we want to retain the notion that 'function' is just syntactic sugar 
for the equivalent initialized declaration involving 'func', then we're a 
bit limited in what we can do.  I think the current notion that any new 
variable declaration creates a new variable is valuable, so that leaves us 
with some questions on how this would work:

	int function foo (int x);

	<1. expressions involving foo>

	int foo = 12;

	<2. expressions involving foo>

	int function foo (int x) { return x + 1; }

Is this legal?  If not, which line is erroneous?  Our current scheme is a 
bit ugly, but at least semantically clear; I believe any new scheme should 
reflect those semantics while making the syntax clearer.

Keith Packard        XFree86 Core Team        Compaq Cambridge Research Lab