[Nickle]import and existing names

Keith Packard keithp@keithp.com
Tue, 06 Mar 2001 23:20:02 -0800


Here's a scenario:

public integer    i  = 1;
public *integer p_i  = &i;
public *integer q_i = &i;

namespace n {
    public integer    i = 2;
    public *integer p_i = &i;
}

import n;
i = 3;
n.i = 4;

What should the values of the following expressions be:

	i
	*p_i
	*q_i
	n.i
	*n.p_i

I thought (just for a minute), that importing symbols should be equivalent 
to declaring them at the outer scope; declarations now re-use existing 
global symbols when the types match so that you can redefine functions and 
have existing code use the new functions.  The old global symbol simply 
gets a new value.

This doesn't work with import -- those imported symbols may well have 
references that will still point to the nested symbol and not the existing 
global one.

The only consistent symantic I can think of is that import *and* 
redefinition *both* remove any existing symbol and replace it with the new 
one.  Pointers to the old symbol will continue to reference the old object 
while new code referencing the name will get the new object.

I'll implement this, at least for now, the alternative is chaos.

-keith