[#87773] timer thread [was Re: [ruby-alerts:7905] failure alert on trunk-asserts@silicon-docker (NG (r63844))] — Eric Wong <normalperson@...>
> test_all <main>: warning: pthread_create failed for timer: Resource temporarily unavailable, scheduling broken
[#87836] [Ruby trunk Bug#14898] test/lib/test/unit/parallel.rb: TestSocket#test_timestamp stuck sometimes — ko1@...
Issue #14898 has been reported by ko1 (Koichi Sasada).
[email protected] wrote:
On 2018/07/06 18:47, Eric Wong wrote:
[#87847] undefined symbol: mjit_init_p — Leam Hall <leamhall@...>
I pulled Ruby trunk on 3 Jul and am now getting errors similar to the
QXMgSSB0b2xkIHlvdSwgYG1ha2UgaW5zdGFsbGAgaXMgbmVlZGVkIHRvIG1ha2UgUnVieSB3b3Jr
T25lIG1vcmUgcmVhc29uIGZvciBodHRwczovL2J1Z3MucnVieS1sYW5nLm9yZy9pc3N1ZXMvMTM2
[#87986] [Ruby trunk Feature#14915] Deprecate String#crypt, move implementation to string/crypt — mame@...
Issue #14915 has been updated by mame (Yusuke Endoh).
[email protected] wrote:
normalperson (Eric Wong) wrote:
[#88088] [Ruby trunk Misc#14937] [PATCH] thread_pthread: lazy-spawn timer-thread only on contention — normalperson@...
Issue #14937 has been reported by normalperson (Eric Wong).
[#88104] [Ruby trunk Bug#14898] test/lib/test/unit/parallel.rb: TestSocket#test_timestamp stuck sometimes — ko1@...
Issue #14898 has been updated by ko1 (Koichi Sasada).
[#88173] [Ruby trunk Bug#14950] r64109 thread.c: move ppoll wrapper before thread_pthread.c - Windows compile failure - thread.c — Greg.mpls@...
Issue #14950 has been reported by MSP-Greg (Greg L).
[#88189] [Ruby trunk Bug#14950] r64109 thread.c: move ppoll wrapper before thread_pthread.c - Windows compile failure - thread.c — nobu@...
Issue #14950 has been updated by nobu (Nobuyoshi Nakada).
[#88199] [Ruby trunk Misc#14937] [PATCH] thread_pthread: lazy-spawn timer-thread only on contention — takashikkbn@...
Issue #14937 has been updated by k0kubun (Takashi Kokubun).
[email protected] wrote:
> yet, sky3 had a failure at
> http://ci.rvm.jp/results/trunk@P895/1173951
> > http://ci.rvm.jp/results/trunk@P895/1173951
[ruby-core:87989] [Ruby trunk Feature#14912] Introduce pattern matching syntax
Issue #14912 has been updated by shyouhei (Shyouhei Urabe).
We had some in-detail discussuion about the possibility of this issue in todays developer meeting. Though it seemed a rough cut that needs more brush-ups, the proposal as a whole got positive reactions. So please continue developing.
Some details the attendees did not like:
- Deconstruction seems fragile; For instance the following case statement matches, which is very counter-intuitive.
```ruby
def foo(obj)
case obj
in a, 1 => b, c then
return a, b, c
else
abort
end
end
A = Struct.new(:x, :y)
p foo(A[1, 2]) # => [A, 1, 2]
```
- There is `|` operator that is good. But why don't you have counterpart `&` operator?
- Pinning operator is necessary. However the proposed syntax do not introduce an _operator_ rather it introduces naming convention into local variable naming. This is no good. We need a real operator for that purpose.
- One-liner mode seems less needed at the moment. Is it necessary for the first version? We can add this later if a real-world use-case is found that such shorthand is convenient, rather than cryptic.
- Some attendees do not like that arrays cannot be pattern matched as such.
```ruby
case [1, 2, [3, 4]]
in [a, b, [3, d]] # <- unable to do this
...
end
```
- Should `#deconstruct` be called over and over again to the same case target? Shouldn't that be cached?
But again, these points are about details. The proposal as a whole seemed roughly okay.
----------------------------------------
Feature #14912: Introduce pattern matching syntax
https://bugs.ruby-lang.org/issues/14912#change-73001
* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I propose new pattern matching syntax.
# Pattern syntax
Here's a summary of pattern syntax.
```
# case version
case expr
in pat [if|unless cond]
...
in pat [if|unless cond]
...
else
...
end
pat: var # Variable pattern. It matches any value, and binds the variable name to that value.
| literal # Value pattern. The pattern matches an object such that pattern === object.
| Constant # Ditto.
| var_ # Ditto. It is equivalent to pin operator in Elixir.
| (pat, ..., *var, pat, ..., id:, id: pat, ..., **var) # Deconstructing pattern. See below for more details.
| pat(pat, ...) # Ditto. Syntactic sugar of (pat, pat, ...).
| pat, ... # Ditto. You can omit the parenthesis (top-level only).
| pat | pat | ... # Alternative pattern. The pattern matches if any of pats match.
| pat => var # As pattern. Bind the variable to the value if pat match.
# one-liner version
$(pat, ...) = expr # Deconstructing pattern.
```
The patterns are run in sequence until the first one that matches.
If no pattern matches and no else clause, NoMatchingPatternError exception is raised.
## Deconstructing pattern
This is similar to Extractor in Scala.
The patten matches if:
* An object have #deconstruct method
* Return value of #deconstruct method must be Array or Hash, and it matches sub patterns of this
```
class Array
alias deconstruct itself
end
case [1, 2, 3, d: 4, e: 5, f: 6]
in a, *b, c, d:, e: Integer | Float => i, **f
p a #=> 1
p b #=> [2]
p c #=> 3
p d #=> 4
p i #=> 5
p f #=> {f: 6}
e #=> NameError
end
```
This pattern can be used as one-liner version like destructuring assignment.
```
class Hash
alias deconstruct itself
end
$(x:, y: (_, z)) = {x: 0, y: [1, 2]}
p x #=> 0
p z #=> 2
```
# Sample code
```
class Struct
def deconstruct; [self] + values; end
end
A = Struct.new(:a, :b)
case A[0, 1]
in (A, 1, 1)
:not_match
in A(x, 1) # Syntactic sugar of above
p x #=> 0
end
```
```
require 'json'
$(x:, y: (_, z)) = JSON.parse('{"x": 0, "y": [1, 2]}', symbolize_names: true)
p x #=> 0
p z #=> 2
```
# Implementation
* https://github.com/k-tsj/ruby/tree/pm2.7-prototype
* Test code: https://github.com/k-tsj/ruby/blob/pm2.7-prototype/test_syntax.rb
# Design policy
* Keep compatibility
* Don't define new reserved words
* 0 conflict in parse.y. It passes test/test-all
* Be Ruby-ish
* Powerful Array, Hash support
* Encourage duck typing style
* etc
* Optimize syntax for major use case
* You can see several real use cases of pattern matching at following links :)
* https://github.com/k-tsj/power_assert/blob/8e9e0399a032936e3e3f3c1f06e0d038565f8044/lib/power_assert.rb#L106
* https://github.com/k-tsj/pattern-match/network/dependents
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>