search
Log In
0 votes
569 views
Will recursion work correctly in a language with static allocation of all variables? Explain.
in Compiler Design 569 views

1 Answer

12 votes

Recursion can not be used for static variables since the memory for static variables are allocated only once . so if we use recursion, then it  may give incorrect result . Generally, we do not want such things when implementing recursion.

For detailed explanation, refer http://stackoverflow.com/questions/10290527/why-do-static-variables-not-allow-recursion


edited by

Related questions

1 vote
1 answer
1
601 views
Indicate the result of the following program if the language uses (i) static scope rules and (ii) dynamic scope rules. var x, y:integer; procedure A (var z:integer); var x:integer; begin x:=1; B; z:= x end; procedure B; begin x:=x+1 end; begin x:=5; A(y); write (y) ...end.
asked Dec 3, 2016 in Compiler Design makhdoom ghaya 601 views
14 votes
1 answer
2
2.4k views
In which of the following case(s) is it possible to obtain different results for call-by-reference and call-by-name parameter passing? Passing an expression as a parameter Passing an array as a parameter Passing a pointer as a parameter Passing as array element as a parameter
asked Jan 22, 2016 in Compiler Design Cruise Device 2.4k views
0 votes
0 answers
3
310 views
Consider the following grammar for variable declarations: <vardecl> $\rightarrow$ <vardecl><idlist> : <type>; <vardecl> $\rightarrow \in$ <idlist> $\rightarrow$ <idlist>, id <idlist> $\rightarrow$ id <type> $\rightarrow$ integer <type> ... error messages wherever necessary. Make suitable assumptions regarding procedures operating on the symbol table; you need not elaborate upon these procedures.
asked Dec 5, 2016 in Compiler Design makhdoom ghaya 310 views
0 votes
0 answers
4
187 views
Provide short answers to the following questions: Consider the definition of macro B, nested within the definition of a macro A. Can a call to macro B also appear within macro A? If not, why not? If yes, explain if there are any restrictions.
asked Nov 30, 2016 in Compiler Design makhdoom ghaya 187 views
...