News for hackers. Stuff that matters.
Re:Long live the callbacks by ulisesrmzroche on Thursday August 22, 2013 @12:52PM (#6258292)
From my cold-dead hands you'll take closures away from me.

(function(){})()

They're a great part of JS these mathemagics.

Re:Long live the callbacks by anonymoushn on Thursday August 22, 2013 @01:01PM (#6258346)
An IIFE is more like a block. Check it!

  do end
Re:Long live the callbacks by ulisesrmzroche on Thursday August 22, 2013 @01:09PM (#6258408)
Ruby blocks?
Re:Long live the callbacks by anonymoushn on Thursday August 22, 2013 @01:12PM (#6258434)
C blocks:

  {}
  do{}while(0);
Re:Long live the callbacks by ulisesrmzroche on Thursday August 22, 2013 @01:22PM (#6258498)
I'm not completely getting what parts of them you think make them seem more like c blocks. Could you clear this up a bit?
Re:Long live the callbacks by anonymoushn on Thursday August 22, 2013 @01:56PM (#6258773)
The use case for an IIFE (if you do not use its return value) is the same as for a block. It just gives you a new lexical scope and you run the code inside it. In Lua or C, you can do this with a block.

If you use the return value of an IIFE, it ends up being more like a block in an expression-oriented language like Scala or Julia.

In general, closures are like closures, but IIFEs just use a closure to do something that every other language does without one.