ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature
@ 2020-10-11 12:03 kazuki
  2020-10-12  1:00 ` [ruby-core:100378] " matz
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: kazuki @ 2020-10-11 12:03 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been reported by ktsj (Kazuki Tsujimoto).

----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100378] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
@ 2020-10-12  1:00 ` matz
  2020-10-12  6:30 ` [ruby-core:100380] " nobu
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: matz @ 2020-10-12  1:00 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by matz (Yukihiro Matsumoto).


Agreed.

I have a secret plan to make right hand assignment a replacement for single line pattern match. But it's another story.

Matz.


----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-87989

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100380] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
  2020-10-12  1:00 ` [ruby-core:100378] " matz
@ 2020-10-12  6:30 ` nobu
  2020-10-12  7:17 ` [ruby-core:100381] " matz
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nobu @ 2020-10-12  6:30 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by nobu (Nobuyoshi Nakada).


matz (Yukihiro Matsumoto) wrote in #note-1:
> I have a secret plan to make right hand assignment a replacement for single line pattern match. But it's another story.

Maybe, is this the kind of thing?

https://github.com/nobu/ruby/pull/new/assoc-pattern-matching

----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-87992

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100381] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
  2020-10-12  1:00 ` [ruby-core:100378] " matz
  2020-10-12  6:30 ` [ruby-core:100380] " nobu
@ 2020-10-12  7:17 ` matz
  2020-10-12  7:45 ` [ruby-core:100382] " nobu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: matz @ 2020-10-12  7:17 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by matz (Yukihiro Matsumoto).


Seems like so.

Matz.


----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-87993

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100382] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
                   ` (2 preceding siblings ...)
  2020-10-12  7:17 ` [ruby-core:100381] " matz
@ 2020-10-12  7:45 ` nobu
  2020-10-12 12:16 ` [ruby-core:100387] " matz
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nobu @ 2020-10-12  7:45 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by nobu (Nobuyoshi Nakada).


It disallows assignments to other than local variables.

https://github.com/nobu/ruby/runs/1240626799#step:15:315
```
SyntaxError: (eval):1: syntax error, unexpected instance variable
def self.inc(x) = x + 1 => @x
                           ^~
```


----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-87994

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100387] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
                   ` (3 preceding siblings ...)
  2020-10-12  7:45 ` [ruby-core:100382] " nobu
@ 2020-10-12 12:16 ` matz
  2020-10-12 21:55 ` [ruby-core:100389] " daniel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: matz @ 2020-10-12 12:16 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by matz (Yukihiro Matsumoto).


That's true. Hmm.

Matz.


----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-87999

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100389] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
                   ` (4 preceding siblings ...)
  2020-10-12 12:16 ` [ruby-core:100387] " matz
@ 2020-10-12 21:55 ` daniel
  2020-10-13 13:13 ` [ruby-core:100390] " dementiev.vm
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: daniel @ 2020-10-12 21:55 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by Dan0042 (Daniel DeLorme).


matz (Yukihiro Matsumoto) wrote in #note-1:
> I have a secret plan to make right hand assignment a replacement for single line pattern match.

I find myself liking this idea a lot.

In #13683 nobu suggested pattern matching as a replacement for `v = ary.single`, and while `ary in [v]` is conceptually elegant, `ary => [v]` feels a lot more intuitive. In fact, `expr in pattern` can feel so unintuitive that #16670 even suggested to reverse the order; but this would not be an issue if `=>` was used instead of `in`.

If `=>` does not allow the full range of pattern matching due to syntax restrictions, maybe consider a different operator like `~>` or those I proposed in #16794. And perhaps `~>` as rightward assignment could also be used to resolve the ambiguity of `=>` described in #16960.

----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-88002

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100390] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
                   ` (5 preceding siblings ...)
  2020-10-12 21:55 ` [ruby-core:100389] " daniel
@ 2020-10-13 13:13 ` dementiev.vm
  2020-10-13 16:19 ` [ruby-core:100392] " marcandre-ruby-core
  2020-10-13 16:44 ` [ruby-core:100393] " dementiev.vm
  8 siblings, 0 replies; 10+ messages in thread
From: dementiev.vm @ 2020-10-13 13:13 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by palkan (Vladimir Dementyev).


ktsj (Kazuki Tsujimoto) wrote:
> I propose to promote pattern matching to official feature.
> 
> The current specification is basically fine

I have a little concern regarding the potential changes to the current specification that we might need to introduce to improve the performance.
Recently, we introduced a [deconstructed value caching for array patterns](https://github.com/ruby/ruby/pull/3104), which broke the previous non-documented behaviour: it was possible to return different values for `#deconstruct` call within the same `case..in` statement. Now this is fixed (and the performance is improved).

We still have the same behaviour for #deconstruct_keys (it's possible return different value for two subsequent calls of `#deconstruct_keys([:a])` within the same `case..in`).
I believe, that for the future optimizations of hash patterns (or even more serious internal refactoring for the performance sake), we need to "fix" this edge case as well.

So, my question is: will promoting pattern matching make it harder to introduce breaking changes (even for non-documented edge cases)? And if so, don't we need to make the specification complete first, without such gray zones?

----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-88003

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100392] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
                   ` (6 preceding siblings ...)
  2020-10-13 13:13 ` [ruby-core:100390] " dementiev.vm
@ 2020-10-13 16:19 ` marcandre-ruby-core
  2020-10-13 16:44 ` [ruby-core:100393] " dementiev.vm
  8 siblings, 0 replies; 10+ messages in thread
From: marcandre-ruby-core @ 2020-10-13 16:19 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by marcandre (Marc-Andre Lafortune).


palkan (Vladimir Dementyev) wrote in #note-7:
> I have a little concern regarding the potential changes to the current specification that we might need to introduce to improve the performance.
> Recently, we introduced a [deconstructed value caching for array patterns](https://github.com/ruby/ruby/pull/3104), which broke the previous non-documented behaviour: it was possible to return different values for `#deconstruct` call within the same `case..in` statement. Now this is fixed (and the performance is improved).

I'm glad to read this, I asked for [just that](https://bugs.ruby-lang.org/issues/15881) before 👍
It's a perfectly valid constraint IMO.

I wouldn't be worried about the fact that we aren't yet caching `#deconstruct_keys`. I can't think of a valid use case for replying different values. We can document that this constraint is projected in the future.


----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-88005

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ruby-core:100393] [Ruby master Feature#17260] Promote pattern matching to official feature
  2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
                   ` (7 preceding siblings ...)
  2020-10-13 16:19 ` [ruby-core:100392] " marcandre-ruby-core
@ 2020-10-13 16:44 ` dementiev.vm
  8 siblings, 0 replies; 10+ messages in thread
From: dementiev.vm @ 2020-10-13 16:44 UTC (permalink / raw)
  To: ruby-core

Issue #17260 has been updated by palkan (Vladimir Dementyev).


marcandre (Marc-Andre Lafortune) wrote in #note-8:

> We can document that this constraint is projected in the future.

+1

----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-88006

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-10-13 16:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11 12:03 [ruby-core:100371] [Ruby master Feature#17260] Promote pattern matching to official feature kazuki
2020-10-12  1:00 ` [ruby-core:100378] " matz
2020-10-12  6:30 ` [ruby-core:100380] " nobu
2020-10-12  7:17 ` [ruby-core:100381] " matz
2020-10-12  7:45 ` [ruby-core:100382] " nobu
2020-10-12 12:16 ` [ruby-core:100387] " matz
2020-10-12 21:55 ` [ruby-core:100389] " daniel
2020-10-13 13:13 ` [ruby-core:100390] " dementiev.vm
2020-10-13 16:19 ` [ruby-core:100392] " marcandre-ruby-core
2020-10-13 16:44 ` [ruby-core:100393] " dementiev.vm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).