User Tools


====== Function SHADOW ====== ====Syntax==== * **shadow** //symbol-names// ''&optional //package// → **[[CL:Constant Variables:t]]** ====Arguments and Values==== * //symbol-names// - a //[[CL:Glossary:designator]]// for a //[[CL:Glossary:list]]// of //[[CL:Glossary:symbol name designator|symbol name designators]]//. * //package// - a //[[CL:Glossary:package designator]]//. The default is the //[[CL:Glossary:current package]]//. ====Description==== **shadow** assures that //[[CL:Glossary:symbol|symbols]]// with names given by //symbol-names// are //[[CL:Glossary:present]]// in the //package//. Specifically, //package// is searched for //[[CL:Glossary:symbol|symbols]]// with the //[[CL:Glossary:names]]// supplied by //symbol-names//. For each such //[[CL:Glossary:name]]//, if a corresponding //[[CL:Glossary:symbol]]// is not //[[CL:Glossary:present]]// in //package// (directly, not by inheritance), then a corresponding //[[CL:Glossary:symbol]]// is created with that //[[CL:Glossary:name]]//, and inserted into //package// as an //[[CL:Glossary:internal symbol]]//. The corresponding //[[CL:Glossary:symbol]]//, whether pre-existing or newly created, is then added, if not already present, to the //[[CL:Glossary:shadowing symbols list]]// of //package//. ====Examples==== <blockquote> ([[CL:Functions:package-shadowing-symbols]] ([[CL:Functions:make-package]] 'temp :use '(:cl))) <r>[[CL:Constant Variables:NIL]] </r> ([[CL:Functions:find-symbol]] "CAR" 'temp) <r>CAR :INHERITED </r> (shadow 'car 'temp) <r>T </r> ([[CL:Functions:find-symbol]] "CAR" 'temp) <r>TEMP::CAR :INTERNAL </r> ([[CL:Functions:package-shadowing-symbols]] 'temp) <r>(TEMP::CAR)</r> </blockquote> ------- <blockquote> ([[CL:Functions:make-package]] 'test-1) <r>#<PACKAGE "TEST-1"></r> ([[CL:Functions:intern]] "TEST" ([[CL:Functions:find-package]] 'test-1)) <r>TEST-1::TEST, [[CL:Constant Variables:NIL]]</r> (shadow 'test-1::test ([[CL:Functions:find-package]] 'test-1)) <r>[[CL:Constant Variables:T]]</r> (shadow 'TEST ([[CL:Functions:find-package]] 'test-1)) <r>[[CL:Constant Variables:T]]</r> ([[CL:Macros:assert]] ([[CL:Functions:not]] ([[CL:Functions:null]] ([[CL:Functions:member]] 'test-1::test ([[CL:Functions:package-shadowing-symbols]] ([[CL:Functions:find-package]] 'test-1)))))) <r>[[CL:Constant Variables:NIL]]</r> ([[CL:Functions:make-package]] 'test-2) <r>#<PACKAGE "TEST-2"></r> ([[CL:Functions:intern]] "TEST" ([[CL:Functions:find-package]] 'test-2)) <r>TEST-2::TEST, [[CL:Constant Variables:NIL]]</r> ([[CL:Functions:export]] 'test-2::test ([[CL:Functions:find-package]] 'test-2)) <r>[[CL:Constant Variables:T]]</r> ([[CL:Functions:use-package]] 'test-2 ([[CL:Functions:find-package]] 'test-1)) <r>[[CL:Constant Variables:T]]</r> </blockquote> The **[[CL:Functions:use-package]]** call in the above example does not error, because the //[[CL:Glossary:symbol]]// with name "TEST" is //[[CL:Glossary:shadow|shadowed]]// in the //[[CL:Glossary:package]]// ''test-1''. Therefore, that //[[CL:Glossary:symbol]]// is not found via inheritance from //[[CL:Glossary:package]]// ''test-2'' and there is no conflict between //[[CL:Glossary:symbol|symbols]]// with the same //[[CL:Glossary:name]]//. ====Side Effects==== **shadow** changes the state of the package system in such a way that the package consistency rules do not hold across the change. ====Affected By==== Current state of the package system. ====Exceptional Situations==== None. ====See Also==== * **[[CL:Functions:package-shadowing-symbols|Function PACKAGE-SHADOWING-SYMBOLS]]** * {\secref\PackageConcepts} ====Notes==== If a //[[CL:Glossary:symbol]]// with a name in //symbol-names// already exists in //package//, but by inheritance, the inherited symbol becomes //[[CL:Glossary:shadow|shadowed]]// by a newly created //[[CL:Glossary:internal symbol]]//. \issue{SHADOW-ALREADY-PRESENT:WORKS} \issue{PACKAGE-FUNCTION-CONSISTENCY:MORE-PERMISSIVE} \issue{SHADOW-ALREADY-PRESENT:WORKS} \issue{SHADOW-ALREADY-PRESENT}