Project

General

Profile

Actions

Feature #14709

closed

Proper pattern matching

Added by zverok (Victor Shepelev) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:86667]

Description

On RubyKaigi 2017, there was a presentation of Yuki Torii about possible implementation of pattern matching.

The syntax proposed in presentation was:

res = [:ng, 500]
case res
when %p([:ng, status])
  p status
end

The proposed syntax seem to feel pretty consistent, and the implementation (forked Ruby interpreter) was working at this moment.

As @ko1 (Koichi Sasada) was one of the contributors to the experiment, I don't suppose Ruby core team is not aware of the proposal, so I'd like to know what the status of it? Are there some plans for full-strength pattern matching in Ruby 3 (with proposed, or any other, syntax)?

PS: There are many existing gems with some kind "almost real" pattern matching (including recently emerged Qo), yet I believe that the only useful pattern matching can be provided language core. Otherwise, two main goals can't be achieved:

  • reasonable performance (as the pattern-matching is useful mostly in complicated algorithms, which tend to repeat matches thousands of times);
  • unpacking of parts of the patterns into local variables.

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14912: Introduce pattern matching syntaxClosedktsj (Kazuki Tsujimoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0