Chapter 5 Flashcards
What are variables an abstraction of?
Memory cells that are characterized by attributes
What are some common problems with Names/identifiers?
What form can names take and are there special words reserved (keywords)
What are the aspects of a name?
Length
use of special characters
Case sensitivity
What is the problem when names are too short?
They cannot be connotative
How does Fortran, C99, C++, C#, Ada and Java handle name length?
Fortran = 6 in F1, 31 in F95 and 63 in F 2003
C99 = No limit but only 1st 63 are significant, external names are limited to a max of 31
C++ = No limit but implementers often impose one
C# + ADA + Java = No limit and all are significant
Special Characters in PHP, Perl and Ruby
PHP = All variable names need to start with $
Perl = Scalars use $ arrays use @ and hashes use a %
Ruby = Instance variable names begin with @, Class variables names begin with @@
What is the disadvantages Of case sensitivity?
Decreased readability and write-ability
Why are there special words?
To aid in readability by naming actions
Can reserved words be user-defined?
Nope
What is the problem with an excess in special words?
Name collisions are more likely to occur (COBOL has 300 reserved words)
What are the 6 attributes of a variable?
Name
Address
Value
Type
Lifetime
Scope
All variables have names? T/F
F
Can there be different addresses at different execution times for variables?
Yes
What is a alias?
When 2 variables can be used to access the same memory locations (pointers, references, and unions)
Are aliases good for readibility or bad?
Bad (readers must remember all of them)
What is the Value of a variable
Stores the content of a memory location is associated with
What is the l-value of a variable?
The address (l-value = location value)
What is the r-value?
Value of a variable (real value)
What does the type define for variables?
How a value is stored in memory
What are the possible binding times?
Language design time(binding operators symbols to operations)
Language implementation time (binding floating point type to a representation)
Compile time(Binding variable to type in C or Java)
Load time (Binding C++ local static to memory cell)
Runtime (binding nonstatic local variable to a memory cell)
Whats the difference between static binding and Dynamic binding?
Static = occurs before run time
Dynamic = during execution
What is type binding and what are the issues?
Binding of a variable to a type
How is a type specified and when does the binding take place
What is explicit declaration?
statement used to declare types of variables. (int var )
What is implicit declaration?
A default mechanism for specifying variable types.
Used in BASIC, Perl,Ruby, JS, PHP