ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Anyway, I'm impatiently waiting to see how H_TeXMeX_H will implement the suggested code snippet in C, Python, Java (well, the very very latest Java is supposed to have closures).
By the way, delegates (bound object methods passed as functions) were present in Object Pascal and so semantically closures were even there (it was clumsy for some uses, because it was apparently optimized for a fixed use case)
Python supports simple anonymous functions through the lambda form. The executable body of the lambda must be an expression and can't be a statement, which is a restriction that limits its utility. The value returned by the lambda is the value of the contained expression. Lambda forms can be used anywhere ordinary functions can, however these restrictions make it a very limited version of a normal function.
When reading about Haskell, I found that it said all variables were unchangable once they were created, and I understood that this was part of all functional languages. Is this true?
In Haskell variables are immutable; functional language treats functions as first class objects, i.e. functions can be passed as arguments and returned from other functions - mutability is a separate issue.
Immutability allows much better optimizations and formal correctness proofs.
OCaml, for example, allows to explicitly declare a variable or a field mutable, but recommends to do this as seldom as possible and when really needed. The tutorial has examples/explanations on this.
Last edited by Sergei Steshenko; 07-12-2010 at 02:54 PM.