Jump to content

Anonymous recursion: Difference between revisions

Prune {{incorrect}} tags. Ada, Common Lisp and UNIX Shell are incorrect (because the function is not anonymous), but there seems to be no fix.
(Prune {{incorrect}} tags. Ada, Common Lisp and UNIX Shell are incorrect (because the function is not anonymous), but there seems to be no fix.)
Line 26:
 
=={{header|Ada}}==
{{incorrect|Ada|Just making a function invisible is not anonymous recursion. See the talk page for an explanation.}}
In Ada you can define functions local to other functions/procedures. This makes it invisible to outside and prevents namespace pollution.
 
Line 78 ⟶ 77:
 
=={{header|Common Lisp}}==
This puts a function in a local label. The function is not anonymous, but the name <tt>fib1</tt> is local and never pollutes the outside namespace.
 
<lang common lisp>
(defun fib (number)
"Anonymous recursion Fibonacci sequence function."
(if (< number 0)
(error "Error. The number entered: ~A is negative" number)
Line 154 ⟶ 155:
"/home/uDTVwo/prog.fam" prog.__main__:22(PC:132)
</pre>
 
=={{header|Forth}}==
{{incorrect|Forth|Defining an anonymous function is not anonymous recursion. Also,theThe check for a negative argument is not outside the recursion. See the talk page for an explanation.}}
Recursion is always anonymous in Forth, allowing it to be used in anonymous functions.
<lang forth>defer fib
Line 606 ⟶ 608:
 
=={{header|UNIX Shell}}==
{{incorrect|UNIX Shell|Just making a function invisible is not anonymous recursion. See the talk page for an explanation.}}
The shell does not have anonymous functions. Every function must have a name. However, one can create a subshell such that some function, which has a name in the subshell, is effectively anonymous to the parent shell.
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.