[#101179] Spectre Mitigations — Amel <amel.smajic@...>
Hi there!
5 messages
2020/12/01
[#101694] Ruby 3.0.0 Released — "NARUSE, Yui" <naruse@...>
V2UgYXJlIHBsZWFzZWQgdG8gYW5ub3VuY2UgdGhlIHJlbGVhc2Ugb2YgUnVieSAzLjAuMC4gRnJv
4 messages
2020/12/25
[ruby-core:101538] [Ruby master Feature#17406] Add `NoMatchingPatternError#depth`
From:
eregontp@...
Date:
2020-12-19 11:31:35 UTC
List:
ruby-core #101538
Issue #17406 has been updated by Eregon (Benoit Daloze).
How would this work?
Mutating a field of the NoMatchingPatternError in a catch(NoMatchingPatternError) inserted in every `in` and `else`?
Seems rather hacky to me.
----------------------------------------
Feature #17406: Add `NoMatchingPatternError#depth`
https://bugs.ruby-lang.org/issues/17406#change-89320
* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
----------------------------------------
Could we have `NoMatchingPatternError#depth`, returning the number of `case...in...end` an exception has traversed?
```ruby
def show_depth
yield
rescue NoMatchingPatternError => e
puts "Depth: #{e.depth}"
raise
end
show_depth do
case [1,2,3]
in [x, y, z] then
show_depth do
x => [a, b] # => raises NoMatchingPatternError
end
end
end
# Prints "Depth: 0" then "Depth: 1"
```
This could help bring pattern match closer to a language construct people can play with.
Example usecase: implement `Ractor#receive_if` as in https://bugs.ruby-lang.org/issues/17378#note-6
--
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>