[#62297] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap. — Eric Wong <normalperson@...>
[email protected] wrote:
7 messages
2014/05/02
[#62307] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— SASADA Koichi <ko1@...>
2014/05/03
(2014/05/03 4:41), Eric Wong wrote:
[#62402] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— Eric Wong <normalperson@...>
2014/05/05
SASADA Koichi <[email protected]> wrote:
[#62523] [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan — ko1@...
Issue #9632 has been updated by Koichi Sasada.
3 messages
2014/05/11
[#62556] doxygen (Re: Re: [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan) — Tanaka Akira <akr@...>
2014-05-11 8:50 GMT+09:00 Eric Wong <[email protected]>:
3 messages
2014/05/13
[#62727] [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl — Eric Wong <normalperson@...>
rb_unlink_method_entry may cause old_me to be swept before the new
7 messages
2014/05/24
[#63039] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/10
Hi,
[#63077] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/10
SASADA Koichi <[email protected]> wrote:
[#63086] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/11
(2014/06/11 4:47), Eric Wong wrote:
[#63087] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/11
SASADA Koichi <[email protected]> wrote:
[#62862] [RFC] README.EXT: document rb_gc_register_mark_object — Eric Wong <normalperson@...>
Any comment on officially supporting this as part of the C API?
5 messages
2014/05/30
[ruby-core:62458] [ruby-trunk - Feature #9777] Feature Proposal: Proc#to_lambda
From:
xkernigh@...
Date:
2014-05-08 00:28:34 UTC
List:
ruby-core #62458
Issue #9777 has been updated by George Koehler.
Beware! The answer on Stack Overflow (http://stackoverflow.com/a/2946734) is wrong, because it does not preserve the value of `self` in the block.
This is better, but still wrong:
~~~
def convert_to_lambda &block
obj = block.binding.eval('self')
Module.new do
define_method(:_, &block)
return instance_method(:_).bind(obj).to_proc
end
end
~~~
It preserves `self` in the block, but it fails when I pass the lambda to `#instance_exec` or `#module_exec`. I will try to post explanation to Stack Overflow.
There is no way to convert proc to lambda, unless Ruby adds a new feature.
I have no reason to support this new feature. I am not wanting libraries to convert my blocks to lambdas. I know how to use `next`. If someone converts my block to a lambda, then my block can no longer `return` from the enclosing method, or ignore extra arguments. If I want my block to be a lambda, I can write `&->`, as in
~~~
3.times &->(_) { puts "It works!" }
~~~
----------------------------------------
Feature #9777: Feature Proposal: Proc#to_lambda
https://bugs.ruby-lang.org/issues/9777#change-46607
* Author: Richard Schneeman
* Status: Feedback
* Priority: Normal
* Assignee:
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Currently different block objects such as a lambda can be converted into to a proc: http://www.ruby-doc.org/core-1.9.3/Proc.html#method-i-to_proc
However you cannot turn a Proc instance into a lambda. Since a Proc and lambda behave differently sometimes you may want to convert between the two functionalities. One example is a `return` inside of the block. In a lambda the `return` keyword exits the closure, in a Proc the `return` keyword raises an exception.
There is currently no implementation standard way to convert a Proc to a lambda. I made a gem that makes this easier: https://github.com/schneems/proc_to_lambda but it seems overkill.
If MRI introduces a `to_lambda` method on Proc then we can standardize on an interface for this behavior. This question on stack overflow has been upvoted many times: http://stackoverflow.com/questions/2946603/ruby-convert-proc-to-lambda. I think other Ruby developers would like this behavior supported by Ruby core.
--
https://bugs.ruby-lang.org/