ln019 - Memory Locations for Variables Modern programming...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Memory Locations for Variables Modern programming languages have many different classes of Variables, e.g. (1) Global variables (2) Parameters (3) (function) local variables (also called automatic or activation-specific) (4) (object-oriented) member variables (5) Etc. It is the job of the language system to keep track of the values of these variables during the runtime of a program. The language system accomplishes this by binding a variable to a memory location and then uses that memory location to store the value of the variable. Chap 12
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory Locations for Variables In imperative programs this is a fairly transparent process - the assignment operator mimics what happens at the hardware level - namely, the updating of memory cells. In functional languages this is often not so obvious, since there is no global State, but still, variables are bound to memory locations.
Background image of page 2
Activation Records In order to track variables for functions, compilers use a data structure called activation record - collects all the variables belonging to one function into this structure. Example : FORTRAN FUNCTION AVG (M,N) SUM = M + N AVG = SUM/2.0 RETURN END (Main) AVG(4,2) Code: AVG RETURN Global Data: M N SUM <return addr> Activation Record
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Activation Records Note: Non-recursive languages such as FORTRAN keep a single activation
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.

Page1 / 15

ln019 - Memory Locations for Variables Modern programming...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online