Expression closures - use-cases for shortcut lambda syntax (blocks)

Vassily Gavrilyak gavrilyak at
Sat Mar 17 07:44:40 PDT 2007

Nice example of using some lib, that I do not know and can't see what code does.
Let's take a particular function.

addLoadEvent(function() {
     var d = wait(0.5, {data: [["getUsers", "getUsers"], ["foo",

Question - "getUsers", "getUsers" - looks like calling 2 server methods.
Are they executed sequantially or at in parallel, so second call will
be after first is finished? Looks like at the same time, only code
doesn't show this
I would rather like to write such code directly to show my intent clearly.

Now about this
addLoadEvent() {
    connect('bad_example','onclick') {
        var [e] = arguments;

    connect('good_example','onclick') {
        var [e] = arguments;

It it absolutely untyped and use strings for objects and methods.
Also it is uses some signal-slot framework that is not needed in ES at all.
Direct and typed way will look like this

  var badExample = $("bad_example").
  badExample.onClick = (\ e:Event){

  bad_example.showvalue = (\ value:String) { window.alert("badValue:"
+ value) };

  good_example.onclick = (\ e:Event){

  randomObj.showvalue = (\ value){ window.alert("goodValue:" + value) };

So, we typed the example and removed the need for framework.
A bonus - showvalue for random obj and bad_example are now showing
DIFFERENT values, as it will happen often in real code.

Such examples, BTW is clear indication that developers would rather
use some framwork and pass their functions as strings then go with
right and typed way.

Vassily Gavrilyak

More information about the Es4-discuss mailing list