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

Vassily Gavrilyak gavrilyak at gmail.com
Fri Mar 16 15:18:41 PDT 2007


Jeff, concerning who are 'sophisticated' users.

Ruby and Smalltalk and Perl users found nothing sophisticated with blocks.
And most of those users are web-developers, so they will need to deal with
ES anyway.
They are even considered less sophisticated then 'real' Java/C++ developers,
cause of scripting nature.

About current ES user base.
Is seams that most JS libs use (function(){}) trick for namespaces and
function callbacks for AJAX calls.
People are already using the closures and carefully counting the ()s.
Well, actually text editors count them :-).  But that's about writing.
When reading  I do not look at the separators,  just  the  words and
indentation,  and ocasional meaningless
'function' keyword in 'wrong' just breaks the words reading process.

Syntax could be much clearer and I (and most scripters) would be very happy
to have clear blocks like in Ruby.

File.open("file.txt") do  | file
   file.process()
end

or Groovy's

File.open("file"){ file->
   //process
}
Or C#  3
C# 3.0 Specification File.open("file", (file))=>{
   //process
});

But first is not-ES and second is broken with auto semicolon insertion.
May be C# way will be good, and C# is ECMA too. It has the same superfluous
() as ES3, but looks good.
It seems harder to implement and probably can break some syntax, but C# user
base is huge.
Unfortunately I have no better ideas of clear syntax. Seems any nice idea
will break something in current syntax.
Hope it will be born is this discussion.

Vassily Gavrilyak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20070317/ca63cae8/attachment-0002.html 


More information about the Es4-discuss mailing list