(2012/07/21 7:51), Eric Wong wrote:
>> I want to make clear and fix the (1) and (2) before (3).
>> How about it?
> 
> I agree, I want (3) :)
> I'm not sure if the current primitives make it possible to implement (3)
> 
>> A Trivial point.  `res' in block is not a variable (it parsed as method)
>> because the assignment of res (res = ...) is placed after the block.
> 
> Oops, yes, I often forget to declare variables :x
> 
>> One idea is extending ensure semantics.
>> I'm not sure how to design it....
>> We need more ideas.
> 
> What if ensure is made to support parameters?
> 
>   begin
>   ensure Exception => :never
>   end

Introduce new syntax?
It seems difficult to talk matz to introduce it.

But I think it is good syntax (+1).

----

Implementation note:
  Current ensure clause is very light weight.

    begin
      foo
    ensure
      bar
    end

  is same performance as

    foo
    bar

  if foo doesn't raise any exceptions.

  Compiler make duplicated code (bar) like (pseudo-code):

    begin
      foo
      bar
    rescue all exception
      bar
      raise # propagate an exception
    end

  After introducing new syntax, then it will be compiled to:

    begin
      foo
      control_interrupt(...){
        bar
      }
    rescue
      control_interrupt(...){
        bar
      }
      raise
    end

-- 
// SASADA Koichi at atdot dot net