[#6143] — Christophe Poucet <christophe.poucet@...>

Hello,

17 messages 2005/10/04
[#6147] Re: patch.tgz — nobu.nokada@... 2005/10/04

Hi,

[#6199] Kernel rdoc HTML file not being created when rdoc is run on 1.8.3 — James Britt <ruby@...>

When 1.8.3 came out, I grabbed the source and ran rdoc on it. After

9 messages 2005/10/08

[#6251] RubyGems, upstream releases and idempotence of packaging — Mauricio Fern疣dez <mfp@...>

[sorry for the very late reply; I left this message in +postponed and forgot

14 messages 2005/10/12

[#6282] Wilderness: Need Code to invoke ELTS_SHARED response — "Charles E. Thornton" <ruby-core@...>

Testing the My Object Dump and I am trying to cause creation

13 messages 2005/10/14
[#6283] Re: Wilderness: Need Code to invoke ELTS_SHARED response — Mauricio Fern疣dez <mfp@...> 2005/10/14

On Fri, Oct 14, 2005 at 05:04:59PM +0900, Charles E. Thornton wrote:

[#6288] Re: Wilderness: Need Code to invoke ELTS_SHARED response — "Charles E. Thornton" <ruby-core@...> 2005/10/14

Mauricio Fern疣dez wrote:

[#6365] Time for built-in Rational and Complex classes? — Gavin Sinclair <gsinclair@...>

There has been some support for, but no comment on, RCR #260 ("Make

12 messages 2005/10/24
[#6366] Re: Time for built-in Rational and Complex classes? — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/24

On Mon, 24 Oct 2005, Gavin Sinclair wrote:

[#6405] Re: [PATCH] Pathname.exists?() — "Berger, Daniel" <Daniel.Berger@...>

12 messages 2005/10/25
[#6406] Re: [PATCH] Pathname.exists?() — TRANS <transfire@...> 2005/10/25

On 10/25/05, Berger, Daniel <Daniel.Berger@qwest.com> wrote:

[#6408] Re: [PATCH] Pathname.exists?() — Gavin Sinclair <gsinclair@...> 2005/10/25

On 10/26/05, TRANS <transfire@gmail.com> wrote:

[#6442] Wilderness: I Have formatted README.EXT into an HTML Document — "Charles E. Thornton" <ruby-core@...>

I have taken README.EXT (English Version Only) and have reformatted

14 messages 2005/10/27

[#6469] csv.rb a start on refactoring. — Hugh Sasse <hgs@...>

For a database application I found using CSV to be rather slow.

50 messages 2005/10/28
[#6470] Re: csv.rb a start on refactoring. — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/28

[#6471] Re: csv.rb a start on refactoring. — James Edward Gray II <james@...> 2005/10/28

On Oct 28, 2005, at 8:53 AM, Ara.T.Howard wrote:

[#6474] Re: csv.rb a start on refactoring. — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/28

On Fri, 28 Oct 2005, James Edward Gray II wrote:

[#6484] Re: csv.rb a start on refactoring. — James Edward Gray II <james@...> 2005/10/29

On Oct 28, 2005, at 9:58 AM, Ara.T.Howard wrote:

[#6485] Re: csv.rb a start on refactoring. — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/29

On Sat, 29 Oct 2005, James Edward Gray II wrote:

[#6486] Re: csv.rb a start on refactoring. — James Edward Gray II <james@...> 2005/10/29

On Oct 28, 2005, at 8:25 PM, Ara.T.Howard wrote:

[#6487] Re: csv.rb a start on refactoring. — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/29

On Sat, 29 Oct 2005, James Edward Gray II wrote:

[#6491] Re: csv.rb a start on refactoring. — James Edward Gray II <james@...> 2005/10/29

On Oct 28, 2005, at 8:43 PM, Ara.T.Howard wrote:

[#6493] Re: csv.rb a start on refactoring. — James Edward Gray II <james@...> 2005/10/29

On Oct 28, 2005, at 10:06 PM, James Edward Gray II wrote:

[#6496] Re: csv.rb a start on refactoring. — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/29

On Sun, 30 Oct 2005, James Edward Gray II wrote:

[#6502] Re: csv.rb a start on refactoring. — James Edward Gray II <james@...> 2005/10/30

On Oct 29, 2005, at 12:11 PM, Ara.T.Howard wrote:

[#6505] Re: csv.rb a start on refactoring. — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/30

On Mon, 31 Oct 2005, James Edward Gray II wrote:

[#6511] Planning FasterCSV (was Re: csv.rb a start on refactoring.) — James Edward Gray II <james@...> 2005/10/30

I've decided to create a FasterCSV library, based on the code we

[#6516] Re: Planning FasterCSV (was Re: csv.rb a start on refactoring.) — "Ara.T.Howard" <Ara.T.Howard@...> 2005/10/31

On Mon, 31 Oct 2005, James Edward Gray II wrote:

[#6518] Re: Planning FasterCSV (was Re: csv.rb a start on refactoring.) — "NAKAMURA, Hiroshi" <nakahiro@...> 2005/10/31

-----BEGIN PGP SIGNED MESSAGE-----

Re: yield and call not identical?

From: Austin Ziegler <halostatue@...>
Date: 2005-10-07 18:31:22 UTC
List: ruby-core #6193
On 10/7/05, Daniel Amelang <daniel.amelang@gmail.com> wrote:
> I wonder how many people *do* fully understand the whole block/proc/
> lambda/Proc.new/Method/UnboundMethod/etc relationships and the use of
> next/break/redo/return/etc within each of them (not to mention the
> different styles/rules when it comes to parameter lists).
>
> (no, I'm not looking for a comprehensize explanation, just pointing
> out the complexity of the situation)
>
> Often, when a simplification is proposed, it is struck down as 'just a
> way to make it easier for newbies that are still learning the
> language' (ironically, David is oft to say such) and not really a good
> idea.
>
> After 3 years of Ruby programming, I'm still left scratching my head
> at times. Maybe I'm just a little slow.

No, I don't think it's just you. I don't think that your assessment of
David's past comments is fair or accurate. It certainly doesn't match my
recollection of what David has said about the attempts to simplify
block/etc.

I *believe* that what I'm about to say is similar to what David has
said, but it's obviously my interpretation and as such is not to be
taken as "speaking for David".

The problem that I see is that most attempts to "clean up" the block/
proc divide rely on some pretty ugly syntax and have, at least to my
eye, relied more on a theoretical unification than the practical use.
Some attempts have also attempted to eliminate Ruby's pragmatic
one-block case and yield. That is fix is needed may not be in question;
the nature of the fixes provided so far, however, seem to add to the
confusion.

Blocks and Procs are mostly interchangeable. There are some differences
in the way that parameters are handled (block parameters are assigned as
parallel variables; Proc parameters are assigned as function parameters)
and the way that they respond to break and return. There might be other
differences, but these are the major ones. I would argue that the
distinction between the two should be in the *use*, not in the
definition. Specifically:

    def test_yield
      yield 1
    end
    def test_call(&p)
      p.call(1)
    end

    z = lambda { |x, y| [ x, y ] }

    test_yield { |x, y| [ x, y ] }  # => [ 1, nil ]
    test_yield &z                   # => [ 1, nil ]

    test_call { |x, y|  [ x, y ] }  # => [ 1, nil ]
    test_call &z                    # => ArgumentError

To me, the surprising result (I know, I know) is *not* the second
test_yield, but rather the first test_call (mostly because a "puts
p.arity" indicates that the arity is 2 in both cases). In the case of
yield, I don't mind that it's treated as (almost):

    def yield(*args, &block)
      &block.call(*args)
    end

...but for #call, I would want arity respected, whether it's a simple
block or a full lambda. To make this cleaner, it might be better to have
a second method, say #yield (problematic because yield is a keyword, but
something like that) that allows for either style to be called as a
method on the Proc.

I don't have an answer for the other problem (break, return, etc.).

-austin
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca


In This Thread