From: D. Erway
Subject: Newbie Question - Name Shadowing
Date: 
Message-ID: <DERWAY.95Dec14114233@alumni.ndc.com>
I am just getting more seriously involved with Common Lisp, and I just
realized that I have a misconception regarding lexical scoping, and name
shadowing.  I have looked in CLtL2, but cannot find an answer to this
question.

(defun d (x) (* 2 x))

(defun foo (d) (d d))

I would have thought that the use of d in the function name position inside
foo would result in an undefined function error.  Why doesn't the lexical
parameter binding of the name d hide the free function binding?  I assume
name shadowing only occurs for the same type of binding or some such?

Where can I read about this?

Thanks,
Don
From: Lyman S. Taylor
Subject: Re: Newbie Question - Name Shadowing
Date: 
Message-ID: <4aq7tf$2rb@pravda.cc.gatech.edu>
In article <····················@alumni.ndc.com>,
D. Erway <······@ndc.com> wrote:
>
>I am just getting more seriously involved with Common Lisp, and I just
>realized that I have a misconception regarding lexical scoping, and name
>shadowing.  I have looked in CLtL2, but cannot find an answer to this
>question.
>
>(defun d (x) (* 2 x))
>
>(defun foo (d) (d d))
>
>I would have thought that the use of d in the function name position inside
>foo would result in an undefined function error.  Why doesn't the lexical
>parameter binding of the name d hide the free function binding? 

   In Common Lisp there are really two namespaces.  One for symbols and another
   for functions.   If you are just evaluating a symbol for it's value you do
   that in the symbol "namespace".  If you evaluate it for it's function value
   that occurs in the function "namespace".   

   Lexical scoping in each "namespace" is independent.   Therefore in the
   above example when the evaluator looks up "d" in the function namespace
   it obtains the global value.  

   I suppose you could "hide" the global function namespace "d" by creating
   a "label".


>  I assume
>name shadowing only occurs for the same type of binding or some such?

   
>
>Where can I read about this?

   In steele somewhere .... finding the correct page is the magical trick. :-)
   I don't have them at the moment...



-- 
					
Lyman S. Taylor           "Computers are too reliable to replace
(·····@cc.gatech.edu)     	 humans effectively."
			        Commander Nathan Spring, "Starcops"