Important alert: (current site time 7/15/2013 8:33:56 PM EDT)
 

article

Deep vs shallow binding

Email
Submitted on: 7/29/2000 10:54:31 PM
By: Found on the World Wide Web 
Level: Intermediate
User Rating: By 2 Users
Compatibility: 5.0 (all versions), 4.0 (all versions)
Views: 21097
 
     What's the difference between deep and shallow binding?

 
				

In deep binding, lexical variables mentioned in anonymous subroutines are the same ones that were in scope when the subroutine was created. In shallow binding, they are whichever variables with the same names happen to be in scope when the subroutine is called. Perl always uses deep binding of lexical variables (i.e., those created with my()). However, dynamic variables (aka global, local, or package variables) are effectively shallowly bound. Consider this just one more reason not to use them.


Other 100 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

8/28/2004 4:22:21 PM

This is wrong. Deep binding vs shallow binding is an implementation choice for variable binding, not a semantic difference. Both dynamic scoping and lexical scoping can use deep or shallow binding.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.