|
List Info
Thread: Re: lambda with normal block syntax
|
|
| Re: lambda with normal block syntax |

|
2008-05-26 10:48:21 |
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.
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.
|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.
matz.
|
|
| Re: lambda with normal block syntax |
  United States |
2008-05-26 14:59:12 |
If I may, here are two entries from the ChangeLog file:
> Wed Jul 27 16:25:59 2005 Yukihiro Matsumoto
<matz ruby-lang.org>
>
> * parse.y (lambda): Perl6 style -> lambda
expression. [NEW]
> [VERY EXPERIMENTAL]
>
> Tue Dec 25 23:33:55 2007 Yukihiro Matsumoto
<matz ruby-lang.org>
>
> * development version 1.9.0 released.
That is, Matz introduced the -> syntax in mid-2005. There
were two years
and five months for discussion of the feature. And then
1.9.0 was
released at the end of 2007. It seems to me that that
should be the end.
Matz is Ruby's benevolent dictator. He's a smart guy and
he's put a lot
of thought into this. If you like the language he created,
you've got to
trust his ideas about good syntax. (As an aside, I wonder
whether the
Japanese developers on the ruby-dev mailing list give Matz
as much grief
as we seem to here
My understanding is that 1.9.0 is headed, relatively
quickly, toward a
stable 1.9.1 release. If we really don't think that ->
is the optimum
lambda syntax, it seems to me that we should wait until the
2.0
development tree opens.
David Flanagan
|
|
| Re: lambda with normal block syntax |

|
2008-05-26 15:10:16 |
On May 26, 2008, at 2:59 PM, David Flanagan wrote:
> That is, Matz introduced the -> syntax in mid-2005.
There were two
> years and five months for discussion of the feature.
And then 1.9.0
> was released at the end of 2007. It seems to me that
that should be
> the end.
>
> Matz is Ruby's benevolent dictator. He's a smart guy
and he's put a
> lot of thought into this. If you like the language he
created,
> you've got to trust his ideas about good syntax. (As an
aside, I
> wonder whether the Japanese developers on the ruby-dev
mailing list
> give Matz as much grief as we seem to here
>
> My understanding is that 1.9.0 is headed, relatively
quickly, toward
> a stable 1.9.1 release. If we really don't think that
-> is the
> optimum lambda syntax, it seems to me that we should
wait until the
> 2.0 development tree opens.
I disagree strongly. This is the period where we can
actually use 1.9
for real work--until recently it really wasn't the case. And
now,
having used it, we're finding rough edges, and we're
suggesting changes.
Look at the length of this thread, and the near universal
dislike of -
>. Given that passion, and given that 1.9 is still
fluid, what better
time is there to discuss it? Surely making it a part of
1.9.1, which
is considered stable, will make it a lot _harder_ to discuss
and
change, and will give Matz far more grief in terms of
change.
1.9 was released to promote discussion. That's what we're
doing. We
can both update our books as needed when the dust settles
Dave
|
|
| Re: lambda with normal block syntax |

|
2008-05-26 15:11:24 |
|
On Mon, May 26, 2008 at 10:48 AM, Yukihiro Matsumoto < matz ruby-lang.org">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.c om">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
|
| Re: lambda with normal block syntax |

|
2008-05-26 16:58:45 |
+1 to that. I've only now started trying to write a lot of
my
projects in 1.9 and updating my book for 1.9. I'm finding
things I
like and things I don't, but this is one of very few things
that have
really put me off (_fantastic_ job on the updates for the
most part).
I think right now is the time to discuss syntax or library
changes
like this. People are starting to use it and the syntax is
getting
stretched as it's being put to use. I've found in my
tinkering that
most of the changes have streamlined my code, but this one
just...doesn't. It may just be unfamiliarity but I'm having
issues
with both recognition and semantic association.
Cutting off dialog about an issue like this "just
because" seems a
little counter to the core values of an open source project.
I'm
sorry that I didn't notice this problem within whatever
timeline has
been setup, but I think it's major enough to address at any
stage (or
at the very least, discuss).
--Jeremy
On Mon, May 26, 2008 at 4:10 PM, Dave Thomas <dave pragprog.com> wrote:
>
> On May 26, 2008, at 2:59 PM, David Flanagan wrote:
>
>> That is, Matz introduced the -> syntax in
mid-2005. There were two years
>> and five months for discussion of the feature. And
then 1.9.0 was released
>> at the end of 2007. It seems to me that that
should be the end.
>>
>> Matz is Ruby's benevolent dictator. He's a smart
guy and he's put a lot of
>> thought into this. If you like the language he
created, you've got to trust
>> his ideas about good syntax. (As an aside, I wonder
whether the Japanese
>> developers on the ruby-dev mailing list give Matz
as much grief as we seem
>> to here
>>
>> My understanding is that 1.9.0 is headed,
relatively quickly, toward a
>> stable 1.9.1 release. If we really don't think
that -> is the optimum
>> lambda syntax, it seems to me that we should wait
until the 2.0 development
>> tree opens.
>
> I disagree strongly. This is the period where we can
actually use 1.9 for
> real work--until recently it really wasn't the case.
And now, having used
> it, we're finding rough edges, and we're suggesting
changes.
>
> Look at the length of this thread, and the near
universal dislike of ->.
> Given that passion, and given that 1.9 is still fluid,
what better time is
> there to discuss it? Surely making it a part of 1.9.1,
which is considered
> stable, will make it a lot _harder_ to discuss and
change, and will give
> Matz far more grief in terms of change.
>
> 1.9 was released to promote discussion. That's what
we're doing. We can both
> update our books as needed when the dust settles
>
>
>
> Dave
>
>
--
http://jeremymcanally.com/
http://entp.com
Read my books:
Ruby in Practice (http://manning.com/mcana
lly/)
My free Ruby e-book (http://humblelittler
ubybook.com/)
Or, my blogs:
http://mrneighborly.com
http://rubyinpractice.com
a>
|
|
| Re: lambda with normal block syntax |
  United States |
2008-05-26 17:01:40 |
Dave Thomas wrote:
>
> I disagree strongly. This is the period where we can
actually use 1.9
> for real work--until recently it really wasn't the
case. And now, having
> used it, we're finding rough edges, and we're
suggesting changes.
Requesting a major change to the syntax of a language is not
finding a
"rough edge". And I don't believe that any of the
arguments against the
-> syntax are informed by experience gained from
"real work" with 1.9.
These same arguments could have been made two years ago.
(And I suspect
they were made back then. Matz knew that -> was
unpopular before 1.9.0
was released, but he kept the syntax anyway.)
> Look at the length of this thread, and the near
universal dislike of ->.
The thread (and the recent ones like it) are long, but the
number of
contributors isn't that large. What other evidence of
"near universal
dislike" can you cite? (I'm not trying to be
argumentative about that:
I'm just curious about the point. I know it is disliked by a
number of
important and vocal contributors to this list. Do we have
any other
metrics?)
> Given that passion, and given that 1.9 is still fluid,
what better time
> is there to discuss it? Surely making it a part of
1.9.1, which is
> considered stable, will make it a lot _harder_ to
discuss and change,
> and will give Matz far more grief in terms of change.
Matz's standard for language changes after 1.9.0 was
something like (I'm
paraphrasing here) "only if we come to really regret
the decision". The
justification for -> was that it was necessary for
argument defaults. I
(and I assume most of us) accepted it as received wisdom
from Matz,
Nobu, etc., that it was impossible to implement default
arguments with
normal lambda syntax. If Eric Mahurin has truly achieved
the impossible
with his remarkably simple argument defaults patch, then I
suppose that
that might cause Matz to reach the "serious
regret" threshold and
withdraw -> from 1.9. But even if that happens, any
discussion of
alternative syntaxes should really be part of the discussion
of Ruby
2.0, not of Ruby 1.9.1.
But unless Eric's patch changes something, the decision
about -> has
been made, and we need to move on. I believe that Matz has
interesting
features planned for 2.0. Let's look forward to discussing
those rather
than complaining, after the fact, about decisions that have
already been
made for 1.9.
Major kudos to Eric, by the way, for diving in and tackling
the problem
rather than just complaining about it. Most of the
discussion of ->
occurred before Eric's patch, however, and that discussion
was (in my
opinion) inappropriate and disrespectful.
> 1.9 was released to promote discussion. That's what
we're doing. We can
> both update our books as needed when the dust settles
>
Sorry Dave, but that is nonsense. 1.9.0 is not a
"discussion release".
It is an almost-final developer preview release that
requires bug-fixing
and stability improvements before a stable 1.9.1 is
released. The time
for discussion of the language features of 1.9 was the two
or three
years before Christmas 2007. Now is the time for
implementation fixes,
not major language changes.
Here is my understanding of the Ruby 1.9 release history
upon which I
base my assertions: the 1.9 development branch opened up
years ago. It
was originally intended to lead to a stable 2.0 release.
Then Matz
scaled back his plans for the release and decided that the
next release
would not be 2.0. Not wanting to have to call the release
1.10, he
decided that the 1.9 development branch would lead to a
stable 1.9.1
release. Matz set a release date of Christmas 2007 for this
stable
release. Two or three months (if I recall correctly) before
that date,
it became clear to Matz that the implementation of his
multi-lingual
support would not be good enough by then to be called
stable. Rather
than changing the release date, he released 1.9.0 instead of
1.9.1.
My point is this: up until the fall of 2007, we all believed
that a
stable 1.9.1 was to be released very soon. Had the
multi-lingual
changes proved easier to implement, that is what would have
happened.
There was never a plan for an interim "discussion
release". If you
thought you could postpone discussion of key language
features of 1.9
until after the Christmas release, then you just weren't
paying attention.
David Flanagan
>
> Dave
>
>
|
|
| Re: lambda with normal block syntax |

|
2008-05-26 17:37:26 |
On May 26, 2008, at 5:01 PM, David Flanagan wrote:
> My point is this: up until the fall of 2007, we all
believed that a
> stable 1.9.1 was to be released very soon. Had the
multi-lingual
> changes proved easier to implement, that is what would
have
> happened. There was never a plan for an interim
"discussion
> release". If you thought you could postpone
discussion of key
> language features of 1.9 until after the Christmas
release, then you
> just weren't paying attention.
Hmm... I've probably been paying attention to Ruby longer
than most
English-speaking Rubyists (coming up on 10 years now). The
last six
months has probably been the most volatile in the history of
1.9. I'd
say we're still open for discussion
I try hard to give things time to soak in. I have with the
->
business. I've now decided I can live with it, but I'd much,
much
rather not have to. And, with Eric's patch, it's possible we
won't
have to. Like you, I'm grateful to Eric for creating it. And
I'm
grateful that this recent discussion brought it to light, so
we can
now use it to improve Ruby. Had we stifled discussion back
in
December, this wouldn't have happened. So let's continue to
discuss,
and continue to improve.
And, anytime Matz wants to call a feature freeze, he just
has to say.
Dave
|
|
| Re: lambda with normal block syntax |
  United States |
2008-05-26 18:31:53 |
Dave Thomas wrote:
>
> And, anytime Matz wants to call a feature freeze, he
just has to say.
>
I believe that he has all but done that:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-core/14394
|
|
| Re: lambda with normal block syntax |

|
2008-05-26 18:36:50 |
Uh, I'd argue that his condition has been met, but,
obviously, that is
up for debate.
--Jeremy
On Mon, May 26, 2008 at 7:31 PM, David Flanagan
<david davidflanagan.com> wrote:
> Dave Thomas wrote:
>>
>> And, anytime Matz wants to call a feature freeze,
he just has to say.
>>
>
> I believe that he has all but done that:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-core/14394
>
>
>
--
http://jeremymcanally.com/
http://entp.com
Read my books:
Ruby in Practice (http://manning.com/mcana
lly/)
My free Ruby e-book (http://humblelittler
ubybook.com/)
Or, my blogs:
http://mrneighborly.com
http://rubyinpractice.com
a>
|
|
| Re: lambda with normal block syntax |

|
2008-05-26 19:29:09 |
On May 26, 2008, at 6:31 PM, David Flanagan wrote:
> Dave Thomas wrote:
>> And, anytime Matz wants to call a feature freeze,
he just has to say.
>
> I believe that he has all but done that:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-core/14394
>
I believe we're debating his first escape clause.
As for the second, the addition of 300 built-in methods
since then is
a pragmatic indication that stability is relative.
I'm not sure why this is the issue, though.
We're discussing whether we can find a more generally
accepted
notation for ->. Do we need to do that? The consensus
seems to be that
no one likes it, and many people find it confusing, as ->
has
overloaded meanings for them. If everyone who comments on it
finds it
suboptimal, then that might well signify a cognitive design
issue (I'm
not qualified to judge its severity).
But... I think the addition of method-like parameters to
blocks will
remove all objections. -> will no longer be needed, and
people like me
who always mis-type lambda as lamdba will be able to alias
the problem
away. So let's wait for the patch to make it in, then we can
all
experiment with it and give feedback.
Dave
|
|
|
|