closures

Java Closures - Current State

There have been many threads that correspond to this topic. http://stackoverflow.com/questions/116865/whats-the-current-state-of-closures-in-java http://stackoverflow.com/questions/233579/closures-in-java-7 All of the inputs have been that java 7 is NOT getting closures. It seems however closures will now be in java 7: http://weblogs...

Are PHP closures broken or am I missing something?

I've been reading on the new features of PHP 5.3, and one of the major features are closures. Unless I'm very badly mistaken, the PHP developers are either: a) confusing closures with just anonymous functions b) the closures are broken in PHP 5.3.1 in which I'm testing From what wikipedia says closures are the mechanism of anonymous fu...

How to make block local variables the default in ruby 1.9 ?

Hi, Ruby 1.9 gives the ability to define variables that are just local to a block and do not close over variables of the same name in an outer scope: x = 10 proc { |;x| x = 20 }.call x #=> 10 I would like to have this behaviour as default for some blocks i define - without having to use the |;x, y, z| syntax (note the semicolon)....

Is there something like LINQ for Java?

Started to learn LINQ with C#. Especially LINQ to Objects and LINQ to XML. I really enjoy the power of LINQ. I learned that there is something called JLINQ a Jscript implementation. Also (as Catbert posted) Scala will have LINQ Do you know if LINQ or something similar will be a part of Java 7? Update: Interesting post from 2008 - http...

Read/Write Python Closures

Closures are an incredibly useful language feature. They let us do clever things that would otherwise take a lot of code, and often enable us to write code that is more elegant and more clear. In Python, closures are read-only affairs; that is, a function defined inside another lexical scope cannot change variables outside of its local...

Invoking Groovy closures

Hi, If I define a closure in Groovy def c = {println "foo"} I can invoke it using either c() or c.call() AFAIK, these two are identical. However, I recently discovered a third way c.doCall() Are there any differences between call() and doCall() Thanks, Don ...

Javascript Prototypes (the one like Closures not JQuery)

I just picked up a new book on ASP.NET and AJAX and in it there is a sample like this: Person = function(firstName) { this._firstName = firstName; } Person.prototype = { get_FirstName = function() {return this._firstName;} } I noticed immediately this is not what I am used to, and FireBug apparently agrees with me that its wo...

can you say this is a right example of Javascript Closure.. Where the places we need to consider avoiding the closures??

Hi, Problem & Reason One of my team mate ended up in messy situtaion implementing function hooking in javascript. this is the actual code function ActualMethod(){ this.doSomething = function() { this.testMethod(); }; this.testMethod = function(){ alert("testMethod"); }; ...

Bug-free coding with closures (in a non pure virtual environment)

Last days, I am struggling to understand closures. I am very big fan of C# so my main testbed is this language, so I would like to learn about it's closure support. As I studied and experimented, I found out that many people, when trying to blog about closures, they do it by following a completely wrong direction. They project a certain ...

How are closures used in functional languages

For some reason, I tend to associate closures with functional languages. I believe this is mostly because the discussions I've seen concerning closures is almost always in an environment that is focused around functional programming. That being said, the actual practical uses of closures that I can think are are all non-functional in nat...

Javascript: Closures and Callbacks

What are these two? I've yet to find a good explanation of either. ...

What is the best language independent source to learn Lambdas/Closures?

Most programming languages are utilizing lambdas/closures. Which language agnostic source is recommended as the best to learn Lambda basics? Lambdas/Closures in different languages: Perl Lambdas Python Lambdas .Net LINQ Java Closures Scheme Lisp Php Closure and Lambdas Javascript Closures C++ ML Wikipedia: Closures (computer science)...

What am I doing wrong on this simple Closure

Hi all, it maybe sleep deprivation but I cannot understand why this isn't working. I want the onclick to return the value of i from a for loop that created the element and applied the event handler. Have put it in a closure and it is still turning the max number of the iterator. window.onload = function(){ var arbitrary_amount = 100; ...

jQuery-UI Dialog Memory Leaks

I'm working with IE7 and some jQuery dialogs and I'm running into about a 6meg leak per dialog opened. I'm assuming it's to do with closures, but so far everything I've done to remove them haven't helped. At this point I think I've taken care of all the closures except on for a callback function I pass in, but it's still leaking 6 megs e...

Accessing loop iteration in a sub-function?

I'm using the Google Maps API to plot several points on a map. However, in the click event function below, i is always set to 4, i.e. its value after iterating the loop: // note these are actual addresses in the real page var addresses = new Array( "addr 1", "addr 2", "addr 3", "addr 4" ); for (var i = 0; i < addresses.length; i++) { ...

Can anyone describe in a nutshell differences between 3 closures proposals and their current state in Java?

I'm reading about closures which are going to appear in Java 7. And I'm a bit confused because from one hand there are lots of nice articles which describe new java closures. But from the other hand there were 3 different specs and some of the articles are simply outdated because describe not the latest proposal. So, if anyone trac...

JScript.NET private variables

I'm wondering about JScript.NET private variables. Please take a look on the following code: import System; import System.Windows.Forms; import System.Drawing; var jsPDF = function(){ var state = 0; var beginPage = function(){ state = 2; out('beginPage'); } var out = function(text){ if(state == 2){ var st = 3; } M...

Access values of static closure in Groovy

Hello, I'd like to store some properties in a static closure and later access them during a method call: class Person { static someMap = { key1: "value1", key2: "value2" } } So how can I write a method within Person, which retrieves this stored data? Regards, Peter ...

jQuery iterating over a function

Pretty new to jquery and having a bit of a problem with a function I wrote, very similar to this problem, and if that's anything to go on then apparently I have a closure problem. As Peter Bailey put it in the above thread, this is what's happening: Iterate over some values Define/assign a function in that iteration that uses iterated ...

LINQ to Entities - Support for Closures (Lambdas) ?

Hey all I've been working around a problem I have when using LINQ to Entities when using closures. Apparently, L2E does not support closures. Meaning: var users = from user in UserRepository.FindAll() select new UserDTO { UserId = user.UserId, Tickets = from ticket in TicketReposit...