Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. Working with Blocks > Understanding Important Block Scoping

5.2. Understanding Important Block Scoping

If blocks were limited to only utilizing the parameters that were passed to them, and only returning the value that they defined, then it would be a powerful feature in its own right. However, blocks have more tools under the surface that make them even more powerful.

When you define a block inside of another section of code, the block that you define, that is the instructions inside your block, have access not just to all of the normal global variables that all the rest of your code has access to, they also automatically receive read-only copies of all of the stack variables that are within scope in the stack in which the block is defined. This means, that your block has access (read-only) to the entire state of your program as it is running when the block was defined.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint