[#86787] [Ruby trunk Feature#14723] [WIP] sleepy GC — ko1@...
Issue #14723 has been updated by ko1 (Koichi Sasada).
13 messages
2018/05/01
[#86790] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Eric Wong <normalperson@...>
2018/05/01
ko1@atdot.net wrote:
[#86791] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Koichi Sasada <ko1@...>
2018/05/01
On 2018/05/01 12:18, Eric Wong wrote:
[#86792] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Eric Wong <normalperson@...>
2018/05/01
Koichi Sasada <ko1@atdot.net> wrote:
[#86793] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Koichi Sasada <ko1@...>
2018/05/01
On 2018/05/01 12:47, Eric Wong wrote:
[#86794] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Eric Wong <normalperson@...>
2018/05/01
Koichi Sasada <ko1@atdot.net> wrote:
[#86814] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Koichi Sasada <ko1@...>
2018/05/02
[#86815] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Eric Wong <normalperson@...>
2018/05/02
Koichi Sasada <ko1@atdot.net> wrote:
[#86816] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Koichi Sasada <ko1@...>
2018/05/02
On 2018/05/02 11:49, Eric Wong wrote:
[#86847] [Ruby trunk Bug#14732] CGI.unescape returns different instance between Ruby 2.3 and 2.4 — me@...
Issue #14732 has been reported by jnchito (Junichi Ito).
3 messages
2018/05/02
[#86860] [Ruby trunk Feature#14723] [WIP] sleepy GC — sam.saffron@...
Issue #14723 has been updated by sam.saffron (Sam Saffron).
6 messages
2018/05/03
[#86862] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC
— Eric Wong <normalperson@...>
2018/05/03
sam.saffron@gmail.com wrote:
[#86935] [Ruby trunk Bug#14742] Deadlock when autoloading different constants in the same file from multiple threads — elkenny@...
Issue #14742 has been reported by eugeneius (Eugene Kenny).
5 messages
2018/05/08
[#87030] [Ruby trunk Feature#14757] [PATCH] thread_pthread.c: enable thread caceh by default — normalperson@...
Issue #14757 has been reported by normalperson (Eric Wong).
4 messages
2018/05/15
[#87093] [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase — ko1@...
Issue #14767 has been updated by ko1 (Koichi Sasada).
3 messages
2018/05/17
[#87095] [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase — ko1@...
Issue #14767 has been updated by ko1 (Koichi Sasada).
9 messages
2018/05/17
[#87096] Re: [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase
— Eric Wong <normalperson@...>
2018/05/17
ko1@atdot.net wrote:
[#87166] Re: [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase
— Eric Wong <normalperson@...>
2018/05/18
Eric Wong <normalperson@yhbt.net> wrote:
[#87486] Re: [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase
— Eric Wong <normalperson@...>
2018/06/13
I wrote:
[ruby-core:87273] [Ruby trunk Feature#12906] do/end blocks work with ensure/rescue/else
From:
perlun@...
Date:
2018-05-28 12:00:45 UTC
List:
ruby-core #87273
Issue #12906 has been updated by perlun (Per Lundberg).
Old issue, but still perhaps the right place to mention this: the new syntax ONLY works in do/end, not in {} blocks (as mentioned above.)
It also does not work in "block-like" places like a for loop. So this is not valid syntax:
```
for i in 1..100
puts 'hello'
rescue # Syntax error; not valid code in existing Ruby versions like 2.5.0 and 2.5.1.
end
```
Suggested workaround: Use a `(1..100).each do |i|` construct instead. Then you can use a `rescue` or `ensure` within the block in Ruby 2.5 and newer.
(This is actually an arguably valid use case for "fine grained error handling", in cases where the loop can fail in `n` of the `100` cases and you want the failing ones to be ignored. I agree that too-finegrained error handling can otherwise become an antipattern.)
----------------------------------------
Feature #12906: do/end blocks work with ensure/rescue/else
https://bugs.ruby-lang.org/issues/12906#change-72263
* Author: josh.cheek (Josh Cheek)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 2.5
----------------------------------------
When you want to rescue in a block, you must do this:
~~~ruby
lambda do
begin
raise 'err'
rescue
$! # => #<RuntimeError: err>
end
end.call
~~~
I've wished on numerous occasions that I could omit the begin/end and not need the extra wrapper:
~~~ruby
lambda do
raise 'err'
rescue
$! # => #<RuntimeError: err>
end.call
~~~
This would be consistent with how classes and methods work:
~~~ruby
class C
raise 'err'
rescue
$! # => #<RuntimeError: err>
end
send def m
raise 'err'
rescue
$! # => #<RuntimeError: err>
end
~~~
It's not really clear to me how to submit this since it may require some discussion, but this is the diff:
~~~diff
diff --git a/parse.y b/parse.y
index 54ccc52..223e5d3 100644
--- a/parse.y
+++ b/parse.y
@@ -3757,7 +3757,7 @@ brace_body : {$<vars>$ = dyna_push();}
do_body : {$<vars>$ = dyna_push();}
{$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);}
- opt_block_param compstmt
+ opt_block_param bodystmt
{
$$ = new_do_body($3, $4);
dyna_pop($<vars>1);
~~~
I added tests for ensure to rubyspec, but there wasn't an obvious place to talk about rescue/else in this context (the spec for rescue only uses it in a begin/end block) It's probably fine as the spec for ensure does hit rescue, too, and they ultimately delegate to the same pieces. Not totally clear, though. I can do more with that if you need.
~~~diff
diff --git a/language/ensure_spec.rb b/language/ensure_spec.rb
index 13575fc..b14b0b5 100644
--- a/language/ensure_spec.rb
+++ b/language/ensure_spec.rb
@@ -124,3 +124,74 @@ describe "An ensure block inside a method" do
@obj.explicit_return_in_method_with_ensure.should == :ensure
end
end
+
+describe "An ensure block inside a do block" do
+ before :each do
+ ScratchPad.record []
+ end
+
+ it "is executed when an exception is raised in it's corresponding do block" do
+ begin
+ lambda do
+ ScratchPad << :begin
+ raise "An exception occured!"
+ ensure
+ ScratchPad << :ensure
+ end.should raise_error(RuntimeError)
+
+ ScratchPad.recorded.should == [:begin, :ensure]
+ end
+ end
+
+ it "is executed when an exception is raised and rescued in it's corresponding do block" do
+ begin
+ lambda do
+ ScratchPad << :begin
+ raise "An exception occured!"
+ rescue
+ ScratchPad << :rescue
+ ensure
+ ScratchPad << :ensure
+ end.call
+
+ ScratchPad.recorded.should == [:begin, :rescue, :ensure]
+ end
+ end
+
+ it "is executed even when a symbol is thrown in it's corresponding do block" do
+ begin
+ catch(:symbol) do
+ lambda do
+ ScratchPad << :begin
+ throw(:symbol)
+ rescue
+ ScratchPad << :rescue
+ ensure
+ ScratchPad << :ensure
+ end.call
+ end
+
+ ScratchPad.recorded.should == [:begin, :ensure]
+ end
+ end
+
+ it "is executed when nothing is raised or thrown in it's corresponding do block" do
+ lambda do
+ ScratchPad << :begin
+ rescue
+ ScratchPad << :rescue
+ ensure
+ ScratchPad << :ensure
+ end.call
+
+ ScratchPad.recorded.should == [:begin, :ensure]
+ end
+
+ it "has no return value" do
+ lambda do
+ :begin
+ ensure
+ :ensure
+ end.call.should == :begin
+ end
+end
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>