Re: Allen's lambda syntax proposal

2008-12-01 Thread Mark S. Miller
On Mon, Dec 1, 2008 at 8:47 AM, P T Withington [EMAIL PROTECTED] wrote: Eh? So: function () { var foo = 42; {|| var foo = 3; } return foo; } and: function () { var foo = 42; { var foo = 3; } return foo; } Give the same answer? No, because you forgot to call it.

Re: Allen's lambda syntax proposal

2008-12-01 Thread P T Withington
On 2008-12-01, at 11:54EST, Mark S. Miller wrote: On Mon, Dec 1, 2008 at 8:47 AM, P T Withington [EMAIL PROTECTED] wrote: Eh? So: function () { var foo = 42; {|| var foo = 3; } return foo; } and: function () { var foo = 42; { var foo = 3; } return foo; } Give the same answer? No,

Re: Allen's lambda syntax proposal

2008-12-01 Thread Peter Michaux
On Mon, Dec 1, 2008 at 7:31 AM, P T Withington [EMAIL PROTECTED] wrote: On 2008-11-30, at 01:30EST, Brendan Eich wrote: // Instead of lambda (a, b, c) { ... }, why not: { |a, b, c| ... } ? I would rather have a more literate syntax, lest we degenerate to where practically any comic book

Re: Allen's lambda syntax proposal

2008-12-01 Thread Brendan Eich
On Dec 1, 2008, at 10:17 AM, Peter Michaux wrote: On Mon, Dec 1, 2008 at 7:31 AM, P T Withington [EMAIL PROTECTED] wrote: On 2008-11-30, at 01:30EST, Brendan Eich wrote: // Instead of lambda (a, b, c) { ... }, why not: { |a, b, c| ... } ? I would rather have a more literate syntax, lest we

Re: Allen's lambda syntax proposal

2008-12-01 Thread Peter Michaux
On Mon, Dec 1, 2008 at 10:24 AM, Brendan Eich [EMAIL PROTECTED] wrote: On Dec 1, 2008, at 10:17 AM, Peter Michaux wrote: Take an ES program and replace all if-else with ?: and then most functions with {||} and it starts to look quite cryptic. But functions remain. I doubt lambdas in any

RE: Allen's lambda syntax proposal

2008-12-01 Thread Allen Wirfs-Brock
Just to clarify some speculation, the syntax I proposed ({||}) was solely inspired by Smalltalk and tempered by the parsing realities of a C-like syntax. Any similarities to Ruby constructs are probably examples of parallel evolution under similar environmental pressures. I suspect that

Re: Allen's lambda syntax proposal

2008-12-01 Thread Peter Michaux
On Mon, Dec 1, 2008 at 12:19 PM, Allen Wirfs-Brock [EMAIL PROTECTED] wrote: JavaScript already has a concise ASCII vomit syntax for constructing arrays and objects. I didn't mean to imply that JavaScript currently deserves the ASCII vomit label. I also didn't mean to imply the {||} was so bad

Re: Allen's lambda syntax proposal

2008-12-01 Thread Maciej Stachowiak
On Nov 29, 2008, at 10:30 PM, Brendan Eich wrote: At the TC39 meeting two weeks ago in Kona, we had a brief bikeshedding discussion about lambda syntax and why it matters. Observation: blocks in Smalltalk being lightweight means users don't mind writing them for control abstractions,

Re: Allen's lambda syntax proposal

2008-12-01 Thread Breton Slivka
Question: How would I write a recursive function with that syntax? Is there a way to name the lambda, other than var = {||}; ? ___ Es-discuss mailing list Es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Allen's lambda syntax proposal

2008-12-01 Thread P T Withington
On 2008-12-01, at 15:59EST, Maciej Stachowiak wrote: \(a, b, c) { ... } +1 ___ Es-discuss mailing list Es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: RE: Allen's lambda syntax proposal

2008-12-01 Thread Douglas Crockford
Allen Wirfs-Brock wrote: {|a,b,c| ...} or \(a,b,c) {...} or {\(a,b,c) ...} The use of \ slightly bothers me because it is takes a character that now is exclusively used in the lexical (token) grammar ( Unicode escapes, string escapes, line continuations) and gives it syntactic

Re: Allen's lambda syntax proposal

2008-12-01 Thread Felix
@ is unused @(a, b, c){} Douglas Crockford wrote: Allen Wirfs-Brock wrote: {|a,b,c| ...} or \(a,b,c) {...} or {\(a,b,c) ...} The use of \ slightly bothers me because it is takes a character that now is exclusively used in the lexical (token) grammar ( Unicode escapes, string escapes,

Re: RE: Allen's lambda syntax proposal

2008-12-01 Thread Breton Slivka
Is recursion still desirable in this form. If so, then of the three I like \(a,b,c) {} because you can think of the \ as being an abbreviation of function. \ name(a,b,c) {} Just don't start your function name with u. well if we're thinking about lambdas as blocks++, then why not

Re: Allen's lambda syntax proposal

2008-12-01 Thread Felix
oh, right, forgot e4x. ok, one objection to \(){} is that it looks too much like a function. in particular, it feels like I should write var a = \(x){ return x; }; but that isn't right, {||} is sufficiently different that it feels like I should write var a = {|x| x}; Brendan Eich wrote: On

RE: RE: Allen's lambda syntax proposal

2008-12-01 Thread Allen Wirfs-Brock
-Original Message- From: [EMAIL PROTECTED] [mailto:es-discuss- [EMAIL PROTECTED] On Behalf Of Douglas Crockford ... because you can think of the \ as being an abbreviation of function. \ name(a,b,c) {} Just don't start your function name with u. Exactly, that's why I didn't

Re: Allen's lambda syntax proposal

2008-12-01 Thread Maciej Stachowiak
, 2008 12:59 PM To: Brendan Eich Cc: es-discuss@mozilla.org Subject: Re: Allen's lambda syntax proposal On Nov 29, 2008, at 10:30 PM, Brendan Eich wrote: At the TC39 meeting two weeks ago in Kona, we had a brief bikeshedding discussion about lambda syntax and why it matters. Observation: blocks

Re: Allen's lambda syntax proposal

2008-12-01 Thread Maciej Stachowiak
On Dec 1, 2008, at 5:37 PM, Allen Wirfs-Brock wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:es-discuss- [EMAIL PROTECTED] On Behalf Of Douglas Crockford ... because you can think of the \ as being an abbreviation of function. \ name(a,b,c) {} Just don't start your

Re: RE: Allen's lambda syntax proposal

2008-12-01 Thread Peter Michaux
On Mon, Dec 1, 2008 at 5:37 PM, Allen Wirfs-Brock [EMAIL PROTECTED] wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:es-discuss- [EMAIL PROTECTED] On Behalf Of Douglas Crockford ... because you can think of the \ as being an abbreviation of function. \ name(a,b,c) {} Just

Re: Allen's lambda syntax proposal

2008-12-01 Thread David-Sarah Hopwood
Breton Slivka wrote: Is recursion still desirable in this form. If so, then of the three I like \(a,b,c) {} because you can think of the \ as being an abbreviation of function. \ name(a,b,c) {} Just don't start your function name with u. Too ambiguous, even with the space. well

RE: Allen's lambda syntax proposal

2008-12-01 Thread Allen Wirfs-Brock
Below -Original Message- From: Maciej Stachowiak [mailto:[EMAIL PROTECTED] Can you give an example? Since ECMAScript's built-in control structures already have special syntax, it's hard to make anything look *exactly* like them. Here's my best shot at an example. Let's pretend you have a

Re: Allen's lambda syntax proposal

2008-12-01 Thread Peter Michaux
On Mon, Dec 1, 2008 at 9:33 PM, Allen Wirfs-Brock [EMAIL PROTECTED] wrote: The BGGA Java closure proposal attempts to support control abstractions that look like built in control constructs by allowing trailing literal closure arguments to appear after the parenthesized argument list (shades

Re: Allen's lambda syntax proposal

2008-11-30 Thread Peter Michaux
On Sat, Nov 29, 2008 at 11:53 PM, Brendan Eich [EMAIL PROTECTED] wrote: On Nov 29, 2008, at 11:33 PM, Peter Michaux wrote: This would allow writing var foo = {|a, b, c| ...}; which could be written even shorter as var foo(a, b, c) {...}; Why ever would you want to use 'var' there?

Re: Allen's lambda syntax proposal

2008-11-30 Thread Brendan Eich
On Nov 30, 2008, at 12:28 AM, Peter Michaux wrote: On Sat, Nov 29, 2008 at 11:53 PM, Brendan Eich [EMAIL PROTECTED] wrote: On Nov 29, 2008, at 11:33 PM, Peter Michaux wrote: This would allow writing var foo = {|a, b, c| ...}; which could be written even shorter as var foo(a, b, c) {...};

Allen's lambda syntax proposal

2008-11-29 Thread Brendan Eich
At the TC39 meeting two weeks ago in Kona, we had a brief bikeshedding discussion about lambda syntax and why it matters. Observation: blocks in Smalltalk being lightweight means users don't mind writing them for control abstractions, compared to JS functions in ES3. In Smalltalk, ignoring

Re: Allen's lambda syntax proposal

2008-11-29 Thread Peter Michaux
2008/11/29 Brendan Eich [EMAIL PROTECTED]: // Instead of lambda (a, b, c) { ... }, why not: { |a, b, c| ... } ? In know this syntax primarily from Ruby's blocks. This would allow writing var foo = {|a, b, c| ...}; which could be written even shorter as var foo(a, b, c) {...}; The

Re: Allen's lambda syntax proposal

2008-11-29 Thread Breton Slivka
Hey, I like that. In the spirit of fun, here's something that does something weird and random. var fsm = { r: {|| Math.random()0.5}, f: {|a| print(a); ( fsm.r() ? fsm.s : fsm.r() ? fsm.m : {||} )(f);}, s: {|a| print(a); ( fsm.r() ? fsm.m : fsm.r() ? fsm.f : {||} )(s) },

Re: Allen's lambda syntax proposal

2008-11-29 Thread Brendan Eich
On Nov 29, 2008, at 11:33 PM, Peter Michaux wrote: This would allow writing var foo = {|a, b, c| ...}; which could be written even shorter as var foo(a, b, c) {...}; Why ever would you want to use 'var' there? Could foo be reassigned to denote 42, or hello? Syntax for quite different

<    1   2