Talk:Anonymous recursion: Difference between revisions
Content added Content deleted
Line 206: | Line 206: | ||
:Nested functions and binding to a local variable seem equivalent on one level, so maybe nested functions are fine. |
:Nested functions and binding to a local variable seem equivalent on one level, so maybe nested functions are fine. |
||
:--[[User:Dgamey|Dgamey]] 22:01, 20 July 2011 (UTC) |
:--[[User:Dgamey|Dgamey]] 22:01, 20 July 2011 (UTC) |
||
:: It seems that the task just wants the recursive function not polluting global namespace. The AutoHotkey and Forth examples are definitely incorrect. For the nested functions, it depends on if a nested function is visible outside of the scope or not. In most languages it shouldn't be, but not always: if you define a Perl5 function nested inside another function, it's still in the package namespace, not the lexical one. For your list: |
|||
::# Ada I don't know; |
|||
::# C nested function is not visible outside as demonstrated (I wrote it); |
|||
::# C++ nested class definition (actual_fib) is not visible outside; |
|||
::# Common Lisp nested defun (fib1) is not visible; |
|||
::# F# fib2 is not visible; |
|||
::# Factor I have no idea what it's doing, but I guess it effectively creates a one-time eval-ish function to do the recursion; if so it would be ok; |
|||
::# Nemerle does some handwaving, I don't know the actual effect; |
|||
::# Unix shell creates a subshell which aims to not pollute the namespace in parent ''process'', but it does pollute the namespace in the same ''source file''. I would say it's not ok. Then again, you don't tend to write very large programs in shell script, so it's probably moot. |
|||
::--[[User:Ledrug|Ledrug]] 22:44, 20 July 2011 (UTC) |