[#2529] concerns about Proc,lambda,block — "David A. Black" <dblack@...>

Hi --

39 messages 2004/03/01
[#2531] Re: concerns about Proc,lambda,block — ts <decoux@...> 2004/03/01

>>>>> "D" == David A Black <dblack@wobblini.net> writes:

[#2533] Re: concerns about Proc,lambda,block — "David A. Black" <dblack@...> 2004/03/01

Hi --

[#2537] Re: concerns about Proc,lambda,block — matz@... (Yukihiro Matsumoto) 2004/03/01

Hi,

[#2542] Re: concerns about Proc,lambda,block — Mathieu Bouchard <matju@...> 2004/03/02

[#2545] Re: concerns about Proc,lambda,block — matz@... (Yukihiro Matsumoto) 2004/03/02

Hi,

[#2550] Re: concerns about Proc,lambda,block — Mauricio Fern疣dez <batsman.geo@...> 2004/03/03

On Wed, Mar 03, 2004 at 07:51:10AM +0900, Yukihiro Matsumoto wrote:

[#2703] Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...>

This patch adds support to Net::POP for doing POP over SSL. Modeled on how

19 messages 2004/03/27
[#2704] Re: Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...> 2004/03/27

This is v2 of the patch. Cleaned up a bit and added some more docs.

[#2707] Re: Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...> 2004/03/28

v3 of the patch:

[#2721] Re: Proposed patch to add SSL support to net/pop.rb — Minero Aoki <aamine@...> 2004/03/30

Hi,

Re: concerns about Proc,lambda,block

From: matz@... (Yukihiro Matsumoto)
Date: 2004-03-04 00:59:53 UTC
List: ruby-core #2560
Hi,

In message "Re: concerns about Proc,lambda,block"
    on 04/03/04, Dave Thomas <dave@pragprog.com> writes:

|On Mar 3, 2004, at 17:02, Yukihiro Matsumoto wrote:
|> |Matz: have you had a chance to read these pages? Are they technically
|> |accurate?
|>
|> No.  Where can I read your "writeup"?
|
|http://www.pragmaticprogrammer.com/extracts/blocks.pdf

I checked.  Some of your description is based on bugs I fixed already.
For example,

  def meth1(&block)
    block.call
  end

  res = meth1 do
    break 99
  end

This code does not raise exception any longer.  There are no such
things like iterator context and closure context in Procs.  There are
several basic rules:

  * a Proc is a wrapper for a block attached to the method.
  * break and return cause LocalJumpError when a proc is executed
    (by Proc#call) after passing attached method invocation.  We call
    it orphan proc, but you may name it a better name.
  * a Proc from "lambda" catches LocalJumpError caused by break and
    return from within its body, then terminates the execution
    gracefully.
  * use of "Kernel#proc" is no longer encouraged; use "lambda"
    instead.  

In the above example, block is called within "meth1" which the block
is attached to, so that block is not orphan, no exception;  whereas

  def meth2(&block)
    block
  end
  b = meth2{break 99}
  res = b.call

should cause LocalJumpError, because a Proc is called after the
execution of meth2.

							matz.

In This Thread