We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS


Can someone explain why the heck the syntax for a lambda is "function(x) x*x"  ?? Lookit that, I don't have to type quite nearly as much! The obvious problem is that gigantic frelling keyword at the beginning. Why can it just be something like { x, y | x*y } or something nice and simple like that? Or maybe, taking hints from Functional Javascript, just something like { x*y }, where the order of the variables in the braces defines the order in the arguments list. I mean that makes much more sense, doesn't it?


document.addEventListener("click", function() false, true);

..., really that much shorter than...

document.addEventListener("click", function(){ return false }, true);

...? No not really. But sure...

document.addEventListener("click", {false}, true);

... is an even better improvement, yes?

I suggest you read through some of the voluminous discussions on es4-discuss on this topic. Various alternatives were suggested; in the end I think it came down to function being an easy way to find functions in context, other options requiring unbounded forward-parsing (as opposed to single-token lookahead or similar), and the requirement to use backward-compatible syntax (in that it doesn't conflict with existing syntax), and just readability in general (writability not being everything, especially long-term -- you read code much more than you write it). In particular I note your last example conflicts with object literals (possibly some definitions might not, but it's hard to say with just one example), the first conflicts with destructuring assignment (a new feature in ES4 to allow you to easily extract portions of an object or array, motivated by Python's destructuring assignment for tuples) unless you introduce unbounded lookahead, and the second (at least to me) is unintuitive if the order determines the arguments (and what about name hiding? it gets messy fast). Anyway, read the thread, think about conflicting with existing syntax, and consider readability. Do feel free to bring up any concerns you have after doing so on es4-discuss. --Waldo 01:42, 9 August 2007 (PDT)

Document Tags and Contributors

Contributors to this page: Waldo, Psygnisfive
Last updated by: Waldo,