[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


	From: jeff%aiva.edinburgh.ac.uk%nss.cs.ucl.ac.uk%ngp.utexas.edu@RELAY.CS.NET Dalton <jeff%aiva.edinburgh.ac.uk@nss.cs.ucl.ac.uk>
	Date: Wed, 16 Dec 87 20:03:23 GMT
	Message-Id: <16928.8712162003@aiva.ed.ac.uk>
	To: kcl <@sally.utexas.edu>
	Subject: SHADOWING-IMPORT doesn't

	SHADOWING-IMPORT does not work correctly when there is a conflicting
	symbol in the importing package:

	     KCl (Kyoto Common Lisp)  June 3, 1987

	     >(in-package "A")
	     #<"A" package>
	     A>(defun f () "A")			;F in A
	     A>(in-package "B")
	     #<"B" package>

	     B>(defun f () "B") 		;conflicting F in B

	     B>(shadowing-import 'a::f)		;should work without error

	     Error: Cannot shadowing-import the symbol A::F
	            to #<"B" package>,
	            because there is already a symbol with the same name
	            in the package.
	     Error signalled by SHADOWING-IMPORT.

	According to Steele, p. 179:

	     SHADOW and SHADOWING-IMPORT never signal a name-conflict error
	     [...]  SHADOWING-IMPORT does name-conflict checking to the extent
	     that it checks whether a distince existing symbol with the same
	     name is accessable; if so, it is shadowed by the new symbol, which
	     implies that it must be uninterned if it was directly present in
	     the package.

	What should happen in the example above is that B::F should be uninterned
	and the import should succeed.
	Jeff Dalton,                      JANET: J.Dalton@uk.ac.ed             
	AI Applications Institute,        ARPA:  J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk
	Edinburgh University.             UUCP:  ...!ukc!ed.ac.uk!J.Dalton

There was a bug in the definition of the C function shadowing_import
in file c/package.d.  To fix the bug, use the following definition.

shadowing_import(s, p)
object s, p;
	object x, *ip;

	x = find_symbol(s, p);
	if (intern_flag && intern_flag != INHERITED) {
		if (x == s) {
			if (!member_eq(x, p->p.p_shadowings))
				= make_cons(x, p->p.p_shadowings);
		if(member_eq(x, p->p.p_shadowings))
			delete_eq(x, &p->p.p_shadowings);
		if (intern_flag == INTERNAL)
			delete_eq(x, &p->p.p_internal[pack_hash(x)]);
			delete_eq(x, &p->p.p_external[pack_hash(x)]);
		if (x->s.s_hpack == p)
			x->s.s_hpack = Cnil;
		if ((enum stype)x->s.s_stype != stp_ordinary)
			uninterned_list = make_cons(x, uninterned_list);
	ip = &p->p.p_internal[pack_hash(s)];
	*ip = make_cons(s, *ip);
	p->p.p_shadowings = make_cons(s, p->p.p_shadowings);

-- Taiichi