Sjoerd Visscher's weblog
My ideas about new web technology that can change the future of the world wide web.
< Friday, November 08, 2002 >
What does the scope do?
Because Loell is so centered around scope handling, I needed to think about what the scope is actually for. This is what I came up with:
- Temporary storage. In OO languages there's plenty of opportunity to store data, but storing data in the scope can be good for several reasons: 1. You simply don't need the data anymore at the end of the method. 2. You don't know where the data has to be put, f.e. the return value of a method. 3. You might not have the rights to put data anywhere else.
- Shortcuts. The code to lookup data could be cumbersome or slow. Then it's easier, faster and more readable to put a pointer to that data in a variable.
- Labeling. The code becomes more readable if you put data in a variable that has the proper name for how this data is used in the current context.