2,409 views

1 Answer

Best answer
2 votes
2 votes

Static links refer to the arrangement of procedures in programs when viewed statically. In other words, they are nesting of procedures one inside the other. A static link holds a reference to a procedure within which a procedure is contained.

For example:

main {
  someFunc()    // Invocation
  someFunc {
     // some code for this function
     anotherFunc()   // Invocation
   }
  anotherFunc {
    // some code for this function
  }
}

Since someFunc is contained inside main, a static link to main exists in someFunc. Same is the case for anotherFunc

Dynamic links always refer to the caller of the function, as opposed to static links which refer to scope container.

Since main is invoking someFunc(), so dynamic link in someFunc would hold reference to caller i.e. main

For anotherFunc(), since it is called by someFunc, so dynamic link in anotherFunc would hold reference to caller i.e. someFunc

Reference:

https://www.cs.nmsu.edu/~rth/cs/cs471/f00/ARIs.html

selected by

Related questions

7 votes
7 votes
4 answers
1
2 votes
2 votes
1 answer
2
4 votes
4 votes
1 answer
4
Mk Utkarsh asked Nov 16, 2017
508 views
Does the dynamically linked files are slower in execution as compared to static linked files?