MATH 1P98 Lecture Notes - Lecture 6: Cosc, Instance Variable, Local Variable
raining258 and 36452 others unlocked
99
MATH 1P98 Full Course Notes
Verified Note
99 documents
Document Summary
Cosc 1p02 tutorial exercise 3 feb 4th, 2020. In this exercise we will look at the concepts of scope and parameter passing. Scope rules define which declaration (which actual storage location) is associated with each use of a variable (or other) name. The text (section 3. 6) describes four rules for resolving scope (finding the declaration to which a use refers): Look for a declaration of the name in the method (or constructor) in which the code resides. If one exists, this is the defining declaration. This rule applies to both formal parameter declarations and local declarations. If no such declaration exists, apply step 1 looking in the immediately enclosing code unit normally this would be a class declaration. If no such declaration exists, check the public declarations of public classes from imported packages. This is how the names turtle, forward, pi, and sin that are imported from the media and math packages are resolved.