-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'let': no recursive functions #14
Comments
You can have a recursive local function by first declaring the variable with let and then setting it, e.g. with such a macro:
|
This is wrong! This macro does not actually create a local variable, it works literally as (= reclet (mac (name def)
(list 'do
(list 'let name)
(list '= name def)
)
)) But that macro is useless. So, it looks like in fe you can't create a macro that creates a local variable and does something else in the calling environment.
You can do this following way (just a spontaneous example): (= fib-sqr (fn (x)
; create local recursive function
(let fib nil)
(= fib (fn (x)
(if (<= 2 x) (+ (fib (- x 2)) (fib (- x 1))) x)
))
; call it
(let n (fib x))
(* n n)
)) |
What is a lisp without recursion? Not very useful.
Therefore it is a pity that with fe you cannot specify a recursive function, using 'let'. You are forced to use '=', but then the function gets global scope which is not always wanted.
Maybe there is a small modification possible to solve this problem?
The text was updated successfully, but these errors were encountered: