
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A ml code snippet and instructions for drawing a snapshot of the runtime stack immediately before the last call to the 'plus' function returns to the body of 'repeat'. The necessary components of an activation record and the role of closures. It is a useful resource for students studying functional programming and stack frames.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

1 fun plus(x) = x + 1; 2 fun main(x) = 3 let val y = x + 1 4 in let fun repeat(f,x) = 5 let y = f(x) 6 in f(y) 7 end 8 in repeat(plus, y) 9 end 10 end; 11 main (5); 12
The activation record for each function needs to have a control link, an access link, a return address, a return value address, parameters, and local variables. Remember that function values are represented by closures and that a closure is a pair consisting of an environment (pointer to an activation record) and compiled code. Use the line numbers in the code to indicate the return address of each function call (the line number immediately following the function call). Follow guidelines in lab8.