News for hackers. Stuff that matters.
Re:When is a recursive function not a recursive function? by kazinator on Sunday October 05, 2014 @10:49AM (#8412394)
cdown is not "no longer recursive"!

It is either "still recursive" or "never had been recursive" depending on your point of view.

Evidence for "still recursive": when you call it, the countdown is consed up.

Evidence for "never had been recursive": nowhere in the code was there ever a call to cdown, other than the top-level one.

> (def cdown #'countdown) ... This works but is rather counterintuitive; with a Lisp-1 you get used to refering to functions directly rather than with a quoted symbol, but here we have to use both a quote and a #.

It is counterintuitive not because of Lisp-1 versus Lisp-2 but because in (def cdown countdown) the symbolic reference to the function countdown is immediately evaluated to an object that is bound to cdown, such that cdown doesn't follow a redefinition of countdown. Yet, in (def cdown #'countdown), the #'countdown is deferred so that the countdown symbol is re-evaluated. This means that def has strange evaluation rules, or that #'countdown has nothing to do with the Common Lisp #'countdown: namely, it produces some kind of proxy object which resolves to a function, using late binding with a symbol that is captured in its innards. Or possibly #'countdown produces a wrapper function which takes the call and defers to countdown, by symbol. That's what is "counterintuitive": that countdown and #'countdown do not evaluate to the same thing based on experiences with some other dialect.

There are no comments on this comment yet.