A function (often anonymous) bound to the referencing environment in its original lexical scope in such a way that it will still have access to that environment (its variables and other references) if executed outside that scope.

learn more… | top users | synonyms

2
votes
1answer
68 views

Reimplementation of Underscore _.throttle

I've built a function that mimics _.throttle (returns a new, throttled version of the passed function, that, when invoked repeatedly, will only actually call the original function at most once per ...
1
vote
0answers
63 views

Javascript Class System

Warning: The code snippet does run two alerts, just so you know. I wrote a javascript class system with the idea of making declaration simple and clean and instantiation even simpler, along with ...
2
votes
0answers
48 views

groupJoin() in Swift

I have created the following function in Swift for this library I am writing, which joins two arrays on a key (extracted using given closures), and then groups them by key in a ...
2
votes
1answer
240 views

removeAll(closure) in Swift

From this library I wrote, I have created this function in Swift, but I'm not happy with the implementation. Can anyone suggest a better way to do this? I really don't like changing counters inside ...
1
vote
0answers
42 views

JavaScript nesting XMLHttp requests and in a loop

I am new to JavaScript, especially the wonders of async and closures and would like some help on the attached code. It is in a Chrome extension and retrieves a list of users albums with the Picasa Web ...
2
votes
2answers
44 views

Remove list of files from another list of files by their name

In groovy I have a list of files A and also another list of files B. I want to remove all the files from A that have a filename that also occurs in the list of files B. I wrote the following code: ...
2
votes
0answers
30 views

Using my own Optional type with fold method in groovy

I have written an Optional type in groovy roughly based on java8s Optional. I implemented and use a fold method and would like to know if it can be improved. First, ...
2
votes
0answers
78 views

How common is the use of closure in Lisp?

I'm writing a little tool for mangling MP3 collections and, as a challenge, I decided to write in in Hy, a dialect of Python that uses Lisp syntax. Like every good developer, I wrote out my list of ...
5
votes
1answer
504 views

Closure as UIControlEvents handler

I'm expanding the functionality of this SO answer. Mainly I'm focusing on: You can add as many handlers as you want. You can remove (i.e. cancel) the handler. You can receive the ...
0
votes
1answer
36 views

Object with highest count in a Groovy list

I have a list of Parcel objects and am trying to write a closure that picks the parcel object with highest count: ...
2
votes
1answer
239 views

Sharing a database connection with multiple modules

I am building what essentially could be viewed as a glorified database wrapper as a Python package, where I'm having several classes and functions spread out into different modules. My current problem ...
5
votes
2answers
150 views

'Countdown' Numbers round - combine numbers arithmetically to reach a target

Countdown is a British gameshow where contestants compete in word and number challenges. During the numbers round, six numbers are chosen semi-randomly and the task is to combine them using addition, ...
0
votes
1answer
59 views

Storing array inside closure

Is storing array values inside of a closure considered to be bad practice? I having been trying to decide if I should just use a standard object with key value pair. This is not the method I am ...
6
votes
1answer
347 views

MVC Model validation callback

I have made a simple MVC framework of my own for my personal website to learn a thing or two about how this whole thing even works. I think I've got the idea, but there's one thing I'm not sure about. ...
3
votes
1answer
51 views

Implementing an “Add Company” section in a project

I'm working on avoiding JavaScript that either directly modifies the DOM a ton, contains a ton of anonymous functions, or is encapsulated in giant ...
1
vote
1answer
173 views

Node.js callback closure/scope

Is it a bad idea to use the notfound callback like this? If so, why not? (bad scope/closure? I'm a noob node.js dev.) Is it a bad idea to use the ...
5
votes
1answer
180 views

Closures in C#, necessary or not?

I've written JavaScript for a while, but lately I've been writing a lot of C#. I wanted to write a method that could take the column name of a DataTable and return ...
2
votes
2answers
247 views

Deeper abstracting of code into functions

I created a quiz using the module pattern. My code is as follows: ...
2
votes
1answer
166 views

Is my JavaScript OOP style correct?

I have done the following code for testing a web-service. Is my style correct for using OOP in JavaScript? ...
1
vote
1answer
167 views

JavaScript binding loss with setTimeout

My current task is to extend some JavaScript of a framework we are using. A pop-up should slide in, instead of just appear in the middle of the window. So I have overridden one of the framework's ...
3
votes
1answer
276 views

Correctly dealing with closures and modularity in Javascript

The code below is designed to deal with this situation: There is a Battle environment with Characters; these Characters obviously have certain characteristics and abilities, and they need to be ...
1
vote
3answers
320 views

Cleanest way to close over a counter in CoffeeScript

I haven't spent too much time with CoffeeScript and am trying to have a simple counter: ...
3
votes
2answers
498 views

JavaScript closure: code trivia to keep the event handler separate

Note: This was originally posted at SO, and as per the recommendation moving to this form. In my effort to learn JS on the backdrop of SVG development, I got lot of help from SO so far. The answer ...