The Gateway to Computer Science Excellence
+1 vote
803 views
Can Anyone explain me the difference between Static and Dynamic links in Activation Records With some illustration or eg ?
in Programming by (379 points) | 803 views

1 Answer

+2 votes
Best answer

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

by Loyal (5.5k points)
selected by
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,384 answers
198,541 comments
105,340 users