| Why can't I do the following? (let rec (fn (x) (rec x)))
Is there a technical reason? Is there a better alternative? I am aware that I can use "def" to create named functions, and "rfn" and "afn" to create recursive functions, but what if I want to do this: (let rec (fn (x) (rec x))
(def foo (x) (rec x)))
This is supposed to create a private function "rec" that can call itself, and can also be called by the global function "foo", but is hidden from everything else. Is there a better way to do this? Am I completely wrong in trying to make the recursive function accessible only to "foo"? The following works, but feels clunky to me: (let rec (afn (x) (self x))
(def foo (x) (rec x)))
P.S. This is not the code I'm using; it's used only as an example. If run, it would create an infinite loop.P.P.S. Sorry if this has been brought up before. A quick search on Google didn't bring up anything, but a more thorough search found a similar situation:
http://arclanguage.org/item?id=7815 |