In the journey of ComputerScience a fork was made in the path. One path went upwards to abstraction, one path went downwards towards "the machine". The former developed closures, LISP, and GodClasses (see the PythonLanguage) which have created such excellent creations as Javascript and such, but has turned into a dead end, an AntiPattern.
One must now follow the OneTruePath.
What makes you think that is the one "true" path, as opposed to many others?
See also: ConfusedComputerScience.
The confusion, it seems, is not with ComputerScience. Time to look within, Glasshoppa.
"It seems", he said, substituting a slippery predicate for an actual statement.... I have looked within and to the end of your world. YOU, sir, have not understood.
Then I invite you to show how closures are harmful. Be sure to clearly define what you mean by "closure" and "harmful". Illustrate, if possible, with code.
There are no such "invitations" -- where I do the work for you. I have challenged you. Except for functions, closures are an AntiPattern.
Show me how you implement a "closure" at the machine-level, in assembly, or in standard C without extensions.
Really?
Yes.
{A closure simply captures local variables. Trivial, that.}
It's not that trivial, when one has to maintain references to memory locations.
[It's no worse than anything else you put on the heap.]
Thanks for that article. It shows how convoluted one has to get. He's dropping into assembly from C and pushing things onto a stack. I happen to know that it won't be stable, but will review that information....
Having implemented closures in the RelProject, my experience is that they're straightforward to implement -- not particularly complex or difficult -- and they add to the expressiveness of the language. Whilst not currently exposed in the RelProject's TutorialDee implementation, closures are internally used extensively. Without them, the implementation would have been considerably more complex and difficult. So, for minimal implementation effort, a significant gain. I can't consider that "harmful".
Closures are harmful where garbage collection is unacceptable. See KernelMode?, HardRealTime, or any time OutOfMemory? must be handled gracefully.
Well, yes. But then it's not typical to find closures implemented in languages designed for such (generally) low-level contexts.
See also ObjectOrientedRefactored, MarkJanssen, OneTruePath