lambda 式

をまとめて Redhanded に投げようと思っています。


"★"は、特に自信なし・間違っている自覚あり を表しているので、誰か教えてくださいませ。あと、サンプルが間違っていてもツッコミお願いします。

Matz is thinking about new syntax of block paremter and lambda expression. As it stands, we can't use same syntax as method parameter in block parameter. So he has many ideas, but he doesn't satisfy is not satisfied with these ideas.

Now, we write block parameters like this:
We can write block parameters like this now:

hash.each { |k,v| v ||= "none"; ... }

Following examples mean the same.

  • Anonymous function(★無名関数) like Perl6
hash.each -> (k,v="none") { ... }
hash.each { using k,v="none"; ... }
  • Extend lambda
hash.each(&lambda(k,v="none") { ... })
  • Other sign(★記号 mark? symbol?)
hash.each \(k,v="none") { ... }

He leans toward an example like Perl6, but he waver yet.
He wants a good idea which fulfill below condition:

  • It's able to express anonymous function.
  • It puts in front of paraemters.
  • It's good mix of sign which have not been used until now.
  • Many people feel comfortable (if possible).

What do you think?

ブロックパラメータも、メソッドパラメータと同じように書けるということで、無理やり v="none" なるデフォルト値を入れてみたが、適切だったかかなり疑問。