The Gateway to Computer Science Excellence
+2 votes
241 views
Which of following is correct?

1). Drawback with static allocation is that it does not support recursion.

2). Drawback with stack allocation is that, when function completes its execution it will be popped out from stack..

3). Both are correct

4).None of above
in Compiler Design by Boss (31.2k points) | 241 views

2 Answers

+5 votes
Best answer
1. is correct and recursion can never be done with static allocation.

2. is a bit ambiguous. But assuming a functional language feature, this is also true. In order to return a function, its activation record must be alive even after function run. So, activation record is created on heap and not on stack for these languages.
by Veteran (425k points)
selected by
0
Give a clear explanation for your answer please. The stack supports for LIFO then the function whenever completed it should pop the function is it right?
0

2 option seems to be advantageous. It saves memory thus efficiency?

+1
It depends from what perspective we look at- that is why I told "ambiguous" - it won't be asked such in GATE. This is like saying Java is better than C- each has its advantages.

Putting activation record on stack and regaining memory is best for performance and efficiency. But it lacks flexibility in the sense that a function can no longer be returned by another function - a feature needed for functional language. I guess most of you (even me) have not programmed in functional language and hence cannot understand more on that side. If interested you can see Haswell or even lambda functions in C++11.
0 votes
What is ans???

any one explain pllz???
by Boss (14.7k points)

Related questions

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,647 questions
56,492 answers
195,470 comments
100,766 users