[plt-scheme] Re: I/O therefore no local

From: Noel Welsh (noelwelsh at gmail.com)
Date: Wed Mar 3 05:38:51 EST 2010

On Wed, Mar 3, 2010 at 5:55 AM, wooks <wookiz at hotmail.com> wrote:
> Actual past Exam question
> a) Write X procedure recursively.
> b) What is a disadvantage of recursion
> None really since for while repeat etc are all syntactic sugar for
> programs that can be written tail recursively and the blowing of the
> stack by a recursive process is a consequence of the decision by
> certain compiler writers not to implement TCO.......
> It's not going to get them an A is it? Might even get them an F.

One could write:

"Excessive stack usage, which can lead to the stack running out of
space, is often considered a disadvantage of recursion. However this
disadvantage does not, in fact, exist in well engineered systems. A
tail call is a function call that immediately returns the result of
the called function. For example, the expression

return sin(1.0);

is a tail call as the result of calling sin is immediately returned.
Stack frames do not need to be allocated for tail calls; the callers
frame may be reused in this case. blah blah blah"

The point is, if one gives the expected answer and then demonstrates
knowledge beyond this the marker has no grounds for not marking the
answer correct.


Posted on the users mailing list.