[#16611] lambda, ->, haskell, and so on — Dave Thomas <dave@...>

This is one of those e-mails that I know from the start to be futile, =20=

148 messages 2008/05/01
[#16661] Re: lambda, ->, haskell, and so on — Paul Brannan <pbrannan@...> 2008/05/05

On Thu, May 01, 2008 at 12:26:47PM +0900, Dave Thomas wrote:

[#16662] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/05

Hi --

[#16663] Re: lambda, ->, haskell, and so on — ts <decoux@...> 2008/05/05

David A. Black wrote:

[#16664] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/05

Hi --

[#16682] Re: lambda, ->, haskell, and so on — ara howard <ara.t.howard@...> 2008/05/08

[#16684] Re: lambda, ->, haskell, and so on — Michael Neumann <mneumann@...> 2008/05/08

ara howard wrote:

[#16687] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/08

Hi --

[#16691] Re: lambda, ->, haskell, and so on — "ara.t.howard" <ara.t.howard@...> 2008/05/08

[#16692] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/08

Hi --

[#16695] Re: lambda, ->, haskell, and so on — "ara.t.howard" <ara.t.howard@...> 2008/05/08

[#16705] Re: lambda, ->, haskell, and so on — Evan Phoenix <evan@...> 2008/05/11

Not to throw the whole thread into a tizzy again, but why again is:

[#16708] Re: lambda, ->, haskell, and so on — Nobuyoshi Nakada <nobu@...> 2008/05/11

Hi,

[#16720] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/11

Hi,

[#16721] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/12

Hi --

[#16722] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/12

Hi,

[#16723] Re: lambda, ->, haskell, and so on — Evan Phoenix <evan@...> 2008/05/12

[#16724] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/12

Hi,

[#16726] Re: lambda, ->, haskell, and so on — Nathan Weizenbaum <nex342@...> 2008/05/12

What about "fn" or "fun", for "function"?

[#16728] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/12

Hi,

[#16731] Re: lambda, ->, haskell, and so on — Evan Phoenix <evan@...> 2008/05/12

[#16732] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/12

Hi,

[#16759] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/13

Hi --

[#16766] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/14

Hi,

[#16784] Re: lambda, ->, haskell, and so on — "David A. Black" <dblack@...> 2008/05/18

Hi --

[#16795] Re: lambda, ->, haskell, and so on — Nate_Wiger@... 2008/05/19

On Wed, 14 May 2008, David A. Black wrote:

[#16797] Re: lambda, ->, haskell, and so on — Yukihiro Matsumoto <matz@...> 2008/05/19

Hi,

[#16798] Re: lambda, ->, haskell, and so on — "Christopher Gill" <gilltots@...> 2008/05/19

how about an uppercase lambda (instead of the usual lowercase one)

[#16802] Re: lambda, ->, haskell, and so on — "Suraj N. Kurapati" <sunaku@...> 2008/05/20

Christopher Gill wrote:

[#16843] Re: lambda, ->, haskell, and so on — "Suraj N. Kurapati" <sunaku@...> 2008/05/22

Suraj N. Kurapati wrote:

[#16846] Re: lambda, ->, haskell, and so on — "Berger, Daniel" <Daniel.Berger@...> 2008/05/22

=20

[#16854] Re: lambda, ->, haskell, and so on — "=?ISO-8859-2?Q?Rados=B3aw_Bu=B3at?=" <radek.bulat@...> 2008/05/22

T24gVGh1LCBNYXkgMjIsIDIwMDggYXQgNTozNyBQTSwgQmVyZ2VyLCBEYW5pZWwgPERhbmllbC5C

[#16857] Re: lambda, ->, haskell, and so on — "Jeremy McAnally" <jeremymcanally@...> 2008/05/23

RXZlbiB0aG91Z2ggSSBzZWUgdGhlIHVzZWZ1bG5lc3MsIHRoYXQncyBqdXN0IHVnbHkuCgotLUpl

[#16874] Re: lambda, ->, haskell, and so on — Nate_Wiger@... 2008/05/23

"Jeremy McAnally" <jeremymcanally@gmail.com> wrote on 05/22/2008 05:35:01=20

[#16875] Re: lambda, ->, haskell, and so on — "Nikolai Weibull" <now@...> 2008/05/23

2008/5/23 <Nate_Wiger@playstation.sony.com>:

[#16886] lambda with normal block syntax — "Eric Mahurin" <eric.mahurin@...>

This patch is an independent but related one to my previous one. It can be

64 messages 2008/05/25
[#16895] Re: [PATCH] lambda with normal block syntax — Nobuyoshi Nakada <nobu@...> 2008/05/26

Hi,

[#16900] Re: [PATCH] lambda with normal block syntax — "Eric Mahurin" <eric.mahurin@...> 2008/05/26

On Sun, May 25, 2008 at 8:19 PM, Nobuyoshi Nakada <nobu@ruby-lang.org>

[#16901] Re: [PATCH] lambda with normal block syntax — Yukihiro Matsumoto <matz@...> 2008/05/26

Hi,

[#16902] Re: [PATCH] lambda with normal block syntax — "Suraj N. Kurapati" <sunaku@...> 2008/05/26

Hi,

[#16903] Re: [PATCH] lambda with normal block syntax — Yukihiro Matsumoto <matz@...> 2008/05/26

Hi,

[#16904] Re: [PATCH] lambda with normal block syntax — Dave Thomas <dave@...> 2008/05/26

[#16905] Re: [PATCH] lambda with normal block syntax — Yukihiro Matsumoto <matz@...> 2008/05/26

Hi,

[#16907] Re: [PATCH] lambda with normal block syntax — Dave Thomas <dave@...> 2008/05/26

[#16912] Re: [PATCH] lambda with normal block syntax — Yukihiro Matsumoto <matz@...> 2008/05/26

Hi,

[#16920] Re: [PATCH] lambda with normal block syntax — David Flanagan <david@...> 2008/05/26

If I may, here are two entries from the ChangeLog file:

[#16922] Re: [PATCH] lambda with normal block syntax — Dave Thomas <dave@...> 2008/05/26

[#16927] Re: [PATCH] lambda with normal block syntax — David Flanagan <david@...> 2008/05/26

Dave Thomas wrote:

[#16928] Re: [PATCH] lambda with normal block syntax — Dave Thomas <dave@...> 2008/05/26

[#16929] Re: [PATCH] lambda with normal block syntax — David Flanagan <david@...> 2008/05/26

Dave Thomas wrote:

[#16931] Re: [PATCH] lambda with normal block syntax — Dave Thomas <dave@...> 2008/05/27

[#16946] Re: [PATCH] lambda with normal block syntax — David Flanagan <david@...> 2008/05/27

Dave Thomas wrote:

[#16947] Re: [PATCH] lambda with normal block syntax — James Gray <james@...> 2008/05/27

On May 27, 2008, at 12:33 PM, David Flanagan wrote:

[#16949] Re: [PATCH] lambda with normal block syntax — David Flanagan <david@...> 2008/05/27

James Gray wrote:

Re: [PATCH] lambda with normal block syntax

From: "Eric Mahurin" <eric.mahurin@...>
Date: 2008-05-26 20:11:24 UTC
List: ruby-core #16923
On Mon, May 26, 2008 at 10:48 AM, Yukihiro Matsumoto <matz@ruby-lang.org>
wrote:

> Hi,
>
> In message "Re: [PATCH] lambda with normal block syntax"
>     on Mon, 26 May 2008 23:14:56 +0900, Dave Thomas <dave@pragprog.com>
> writes:
>
> |You asked people to try the patched syntax that allows
> |
> |   meth {|a| a+1}, {|b| b*2}
> |
> |I think that this particular syntax is a lot less obtrusive, and a lot
> |easier to recognize, than
> |
> |   meth -> a { a + 1}, -> b { b * 2 }
> |
> |The first one is obviously a couple of blocks: that's what I read when
> |I see {|a| ...}.
> |
> |It seems that most of the posters on this thread agree. And, using
> |your criteria of "try it for a while and see", I'd judge that people
> |have tried -> for a while, and might well be happier with the {|| }
> |version.
>
> Personally I don't like
>
>   meth {|a| a+1}, {|b| b*2}
>
> which can be parsed
>
>   (meth() {|a| a+1}), ({|b| b*2})
>
> or
>
>   meth({|a| a+1}, {|b| b*2})
>
> or whatever.  I dislike this kind of ambiguity.  In fact, you would
> expect the latter, but I'm afraid Eric's patch gives you the former.


Yes, for compatibility the first interpretation must be used.

Keep in mind that this current syntax has the same issue:

meth {}, {}

except that the {} be a block or a Hash.

This is one of the reasons I most use () around my arguments.

This could be a very evidence of (bad) ambiguity.  That's why I asked
> people to try the patch.
>
> Perhaps it works better with Groovy's semantics of block passing (last
> explicit argument with slightly different call syntax).  But not with
> Ruby's implicit argument style, which I am not going to change.
>
> |I'd also argue that the {|a| } makes for a better language. My
> |experience teaching this stuff shows that people are confused by the
> |large number of different options that surround blocks. Unifying block
> |parameters with method parameters, and then removing the need for this
> |somewhat strange -> notation, will reduce the number of special cases,
> |and make it a lot easier for people to understand the language. And
> |that's a major cognition win.
>
> This notation introduces something new (a block without any attached
> method, or lambda), with syntax almost indistinguishable from existing
> one (a block attached to a method).  I hesitate to give too similar
> syntax to something different.  The point should be how different (in
> recognition) a block without attached method (lambda) and an usual
> block in Ruby.  I see them different (at least in Ruby).  Others may
> not.


Another symbol that has a similar ambiguity that everybody deals with just
fine is "-" (minus).  Depending on the context, it can have two different
meanings:

A-B : binary "-", A - B
-A : unary "-", negative A, equivalent to: 0-A

Similarly, with {|| }, it can have two different meanings depending on the
context:

meth { |args| code } : binary "{", call meth with a block
{ |args| code } : unary "{", lambda, equivalent to: lambda { |args| code }

From this perspective, 0 is to - as lambda is to { || }

I think the biggest problem is that the unary block case (the implicit
lambda) also has additional ambiguity with Hash.  It is unfortunate that |'s
are required in this case (to differentiate with Hash) and the normal block
(binary "{" operator) doesn't require them.  But, I think this trade-off is
better than creating something completely new (i.e. the -> syntax).

|Please, please consider adding both these patches into 1.9.
>
> * block parameter with default argument patch: likely.
> * block without attached method patch: need more persuasion.


Great!  This is the priority I'd like to see them.  If default argument
patch is applied, the various lambda shortcuts ("->", the bare block syntax,
and all other suggestions) aren't necessary and would only be syntactic
sugar.  Personally, I'd rather have the bare block lambda syntax (it matches
the normal blocks we have now) or have no lambda shortcut syntax.

Eric

In This Thread