Question

What is your favorite programming language? List the choices (static vs. dynamic) of that language with reference to type binding, storage binding, and scoping.


0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

c++ is my favorite programming language

TYPE BINDINGS

  • An explicit declaration is a statement in the program that lists variable names and specifies that they are a particular type
  • An implicit declaration is a means of associating variables with types through default conventions instead of declaration statements
  • Both implicit and explicit declarations create static bindings to types
  • declarations specify types and other attributes but do not cause allocation of storage
  • definitions specify attributes and cause storage allocation

DYNAMIC TYPE BINDING

  • In dynamic type binding, the type is not specified by a declaration statement.  Instead, the variable is bound to a type when it is assigned a value in an assignment statement.
  • The primary advantage of dynamic binding of variables to types is that it provides a great deal of programming flexibility.
  • there are 2 disadvantages to dynamic type binding:
  • First, the error detection capability of the compiler is diminished relative to a compiler for a language with static type bindings, because any two types can appear on opposite sides of the assignment operation.
  • In a language with dynamic type binding, no error is detected by the compiler or run-time system.
  • In a language with static type binding, the compiler would detect the error and the program would not get to execution.
  • The second advantage of dynamic type binding is cost.  The cost of implementing dynamic attribute binding is considerable, particularly in execution time

STORAGE BINDING

  • The memory cell to which a variable is bound is somehow must be taken from a pool of available memory.  This process is called allocation.  Deallocation is the process of placing a memory cell that has been unbound from a variable back into the pool of available memory.
  • The lifetime of a variable is the time during which the variable is bound to a specific memory location.
  • Static variables are those that are bound to memory cells before program execution begins and remain bound to those same memory cells until program execution terminates.
  • One advantage of static variables is efficiency.
  • One disadvantage of static binding to storage is reduced flexibility
  • Another disadvantage is that storage cannot be shared among variables
  • Static-dynamic variables are those whose storage bindings are created when their declaration statements are elaborated.  The disadvantages are the run-time overhead of allocation and deallocation and the fact that locals cannot be history sensitive.
  • Explicit heap-dynamic variables are nameless (abstract) memory cells that are allocated and deallocated by explicit run-time instructions specified by the programmer.
  • Implicit heap-dynamic variables are bound to heap storage only when they are assigned values.  The advantage of such variables is that they have the highest degree of flexibility, allowing high generic code to be written.  The disadvantage is the run-time overhead of maintaining all the dynamic attributes.  Another disadvantage is the loss of  some error detection by the compiler.

STATIC SCOPE

  • Binding names to non-local variables is called static scoping.  Static scoping is thus named because the scope of the variable can be statically determined, that is prior to execution.

DYNAMIC SCOPE

  • Dynamic scoping is based on the calling sequence of subprograms, not on their spatial relationship to each other.  But the scope can be determined only at run time.
Add a comment
Know the answer?
Add Answer to:
What is your favorite programming language? List the choices (static vs. dynamic) of that language with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT