* [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
@ 2021-11-04 8:47 Strech (Sergey Fedorov)
2021-11-04 9:17 ` [ruby-core:105929] " nobu (Nobuyoshi Nakada)
` (14 more replies)
0 siblings, 15 replies; 16+ messages in thread
From: Strech (Sergey Fedorov) @ 2021-11-04 8:47 UTC (permalink / raw
To: ruby-core
Issue #18287 has been reported by Strech (Sergey Fedorov).
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105929] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
@ 2021-11-04 9:17 ` nobu (Nobuyoshi Nakada)
2021-11-04 9:22 ` [ruby-core:105930] " nobu (Nobuyoshi Nakada)
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2021-11-04 9:17 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by nobu (Nobuyoshi Nakada).
`nil` means the default behavior, that is `sort: true`.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94470
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105930] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
2021-11-04 9:17 ` [ruby-core:105929] " nobu (Nobuyoshi Nakada)
@ 2021-11-04 9:22 ` nobu (Nobuyoshi Nakada)
2021-11-04 11:32 ` [ruby-core:105932] " Eregon (Benoit Daloze)
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2021-11-04 9:22 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by nobu (Nobuyoshi Nakada).
This is intentional and documented as:
```ruby
# The results which matched single wildcard or character set are sorted in
# binary ascending order, unless false is given as the optional +sort+
# keyword argument. The order of an Array of pattern strings and braces
```
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94471
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105932] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
2021-11-04 9:17 ` [ruby-core:105929] " nobu (Nobuyoshi Nakada)
2021-11-04 9:22 ` [ruby-core:105930] " nobu (Nobuyoshi Nakada)
@ 2021-11-04 11:32 ` Eregon (Benoit Daloze)
2021-11-04 14:36 ` [ruby-core:105938] " jeremyevans0 (Jeremy Evans)
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Eregon (Benoit Daloze) @ 2021-11-04 11:32 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Eregon (Benoit Daloze).
This is inconsistent with basically every Ruby method out there.
For all core methods, either:
* the value is converted to a boolean, and then nil/false mean the same
* the value can only be a boolean, and an ArgumentError/TypeError is raised if it's not `true` or `false`.
* `nil` has a special different meaning than true and than false (e.g., `Kernel#clone`)
I think we should fix this obvious inconsistency which seems to gain nothing.
The docs are easy to update:
> unless a falsey value is given as the optional +sort+ keyword argument.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94473
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105938] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (2 preceding siblings ...)
2021-11-04 11:32 ` [ruby-core:105932] " Eregon (Benoit Daloze)
@ 2021-11-04 14:36 ` jeremyevans0 (Jeremy Evans)
2021-11-05 18:38 ` [ruby-core:105949] " Eregon (Benoit Daloze)
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jeremyevans0 (Jeremy Evans) @ 2021-11-04 14:36 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by jeremyevans0 (Jeremy Evans).
Eregon (Benoit Daloze) wrote in #note-3:
> This is inconsistent with basically every Ruby method out there.
I disagree. It's not uncommon for me to do:
```ruby
def m(opts={})
do_something unless opts[:something] == false
# ...
end
```
I think it is reasonable that a `nil` value is treated the same as not passing a value at all.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94479
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105949] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (3 preceding siblings ...)
2021-11-04 14:36 ` [ruby-core:105938] " jeremyevans0 (Jeremy Evans)
@ 2021-11-05 18:38 ` Eregon (Benoit Daloze)
2021-11-05 19:06 ` [ruby-core:105951] " jeremyevans0 (Jeremy Evans)
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Eregon (Benoit Daloze) @ 2021-11-05 18:38 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Eregon (Benoit Daloze).
@jeremyevans Do you know any other core method with this behavior?
I am sure they are many dozens that meet my criteria above (in fact, all core methods except this one AFAIK).
And BTW I think the code is better without the `== false`, but it doesn't matter, this is core methods, not general Ruby code which has different conventions.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94496
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105951] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (4 preceding siblings ...)
2021-11-05 18:38 ` [ruby-core:105949] " Eregon (Benoit Daloze)
@ 2021-11-05 19:06 ` jeremyevans0 (Jeremy Evans)
2021-11-06 1:24 ` [ruby-core:105952] " nobu (Nobuyoshi Nakada)
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jeremyevans0 (Jeremy Evans) @ 2021-11-05 19:06 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by jeremyevans0 (Jeremy Evans).
Eregon (Benoit Daloze) wrote in #note-5:
> @jeremyevans0 Do you know any other core method with this behavior?
I don't, but I didn't do an audit.
> And BTW I think the code is better without the `== false` (and with `if opts[:something]`)
That changes the behavior if the option is not passed, which is very much not what is desired in cases where `== false` is used. You could switch to `opts.fetch(:something, true)`, and there are cases where I use that approach instead.
> but it doesn't matter, this is core methods, not general Ruby code which has different conventions.
Fair enough. I don't object to changing the behavior, I just think the current behavior is reasonable.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94498
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105952] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (5 preceding siblings ...)
2021-11-05 19:06 ` [ruby-core:105951] " jeremyevans0 (Jeremy Evans)
@ 2021-11-06 1:24 ` nobu (Nobuyoshi Nakada)
2021-11-06 12:19 ` [ruby-core:105960] " Eregon (Benoit Daloze)
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2021-11-06 1:24 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by nobu (Nobuyoshi Nakada).
Eregon (Benoit Daloze) wrote in #note-5:
> @jeremyevans0 Do you know any other core method with this behavior?
There are so many methods that it's hard to name them all.
For instance,
```ruby
Integer("010", nil) #=> 8
```
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94499
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105960] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (6 preceding siblings ...)
2021-11-06 1:24 ` [ruby-core:105952] " nobu (Nobuyoshi Nakada)
@ 2021-11-06 12:19 ` Eregon (Benoit Daloze)
2021-11-06 13:25 ` [ruby-core:105962] " Strech (Sergey Fedorov)
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Eregon (Benoit Daloze) @ 2021-11-06 12:19 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Eregon (Benoit Daloze).
nobu (Nobuyoshi Nakada) wrote in #note-7:
> For instance,
> ```ruby
> Integer("010", nil) #=> 8
> ```
`base` is not a boolean argument ("do this or do not this behavior"), it doesn't apply.
BTW it seems Kernel#Integer ignores the second argument if not an Integer which I argue is a separate bug (`Integer("11", :foobar) => 11`)
The same method actually has a boolean (keyword) argument, exception, and it behaves according to the rules above:
```ruby
> Integer("x", exception: nil)
(irb):3:in `Integer': true or false is expected as exception: nil (ArgumentError)
```
That would also be fine for me, if `Dir.glob(..., sort: v)` raises if `v` if not true or false.
As an example all metprogramming methods which accept an `inherit` argument treat `nil` as `false`:
```ruby
irb(main):006:0> String.instance_methods(true).size
=> 188
irb(main):004:0> String.instance_methods(false).size
=> 129
irb(main):005:0> String.instance_methods(nil).size
=> 129
```
Maybe what I wrote in https://bugs.ruby-lang.org/issues/18287#note-3 wasn't clear?
I'm talking about Ruby code methods which take a boolean/boolean-like argument.
AFAIK all such methods (well, except `Dir.glob(..., sort:)`, which is this issue) respect the rules in that comment.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94507
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:105962] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (7 preceding siblings ...)
2021-11-06 12:19 ` [ruby-core:105960] " Eregon (Benoit Daloze)
@ 2021-11-06 13:25 ` Strech (Sergey Fedorov)
2021-11-18 6:17 ` [ruby-core:106118] " matz (Yukihiro Matsumoto)
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Strech (Sergey Fedorov) @ 2021-11-06 13:25 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Strech (Sergey Fedorov).
Eregon (Benoit Daloze) wrote in #note-8:
> ```ruby
> > Integer("x", exception: nil)
> (irb):3:in `Integer': true or false is expected as exception: nil (ArgumentError)
> ```
I would love to see that explicit behavior, which in my opinion would be less surprising and more straightforward.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94509
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:106118] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (8 preceding siblings ...)
2021-11-06 13:25 ` [ruby-core:105962] " Strech (Sergey Fedorov)
@ 2021-11-18 6:17 ` matz (Yukihiro Matsumoto)
2021-11-18 9:36 ` [ruby-core:106126] " Strech (Sergey Fedorov)
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: matz (Yukihiro Matsumoto) @ 2021-11-18 6:17 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by matz (Yukihiro Matsumoto).
We have never made a consensus that `nil` represents the default value. So we should only accept boolean (true or false) for the value.
Matz.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94715
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:106126] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (9 preceding siblings ...)
2021-11-18 6:17 ` [ruby-core:106118] " matz (Yukihiro Matsumoto)
@ 2021-11-18 9:36 ` Strech (Sergey Fedorov)
2021-11-18 9:37 ` [ruby-core:106127] " Eregon (Benoit Daloze)
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Strech (Sergey Fedorov) @ 2021-11-18 9:36 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Strech (Sergey Fedorov).
matz (Yukihiro Matsumoto) wrote in #note-10:
> We have never made a consensus that `nil` represents the default value. So we should only accept boolean (true or false) for the value.
>
> Matz.
Amazing, will adjust my PR, thanks a lot!
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94724
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:106127] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (10 preceding siblings ...)
2021-11-18 9:36 ` [ruby-core:106126] " Strech (Sergey Fedorov)
@ 2021-11-18 9:37 ` Eregon (Benoit Daloze)
2021-11-18 12:14 ` [ruby-core:106134] " Strech (Sergey Fedorov)
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Eregon (Benoit Daloze) @ 2021-11-18 9:37 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Eregon (Benoit Daloze).
Assignee set to Strech (Sergey Fedorov)
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94725
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
* Assignee: Strech (Sergey Fedorov)
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:106134] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (11 preceding siblings ...)
2021-11-18 9:37 ` [ruby-core:106127] " Eregon (Benoit Daloze)
@ 2021-11-18 12:14 ` Strech (Sergey Fedorov)
2021-11-18 13:15 ` [ruby-core:106137] " Strech (Sergey Fedorov)
2021-11-18 14:34 ` [ruby-core:106146] " Eregon (Benoit Daloze)
14 siblings, 0 replies; 16+ messages in thread
From: Strech (Sergey Fedorov) @ 2021-11-18 12:14 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Strech (Sergey Fedorov).
Ruby PR: https://github.com/ruby/ruby/pull/5142
Ruby specs PR: https://github.com/ruby/spec/pull/899
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94731
* Author: Strech (Sergey Fedorov)
* Status: Open
* Priority: Normal
* Assignee: Strech (Sergey Fedorov)
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:106137] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (12 preceding siblings ...)
2021-11-18 12:14 ` [ruby-core:106134] " Strech (Sergey Fedorov)
@ 2021-11-18 13:15 ` Strech (Sergey Fedorov)
2021-11-18 14:34 ` [ruby-core:106146] " Eregon (Benoit Daloze)
14 siblings, 0 replies; 16+ messages in thread
From: Strech (Sergey Fedorov) @ 2021-11-18 13:15 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Strech (Sergey Fedorov).
nobu (Nobuyoshi Nakada) wrote in #note-14:
> Applied in changeset commit:git|89b440bf724b5e670da0fa31c36a7945a7ddc80f.
>
> ----------
> Expect bool as `sort:` option at glob [Feature #18287]
I understand that my code wasn't optimal due to codebase knowledge, but I thought that I will have a chance to contribute. On one hand – it's cool that now we have a better code, on the other hand – it's quite demotivating to experience such an approach.
Anyway, thanks everyone for your time.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94735
* Author: Strech (Sergey Fedorov)
* Status: Closed
* Priority: Normal
* Assignee: Strech (Sergey Fedorov)
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:106146] [Ruby master Feature#18287] Support nil value for sort in Dir.glob
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
` (13 preceding siblings ...)
2021-11-18 13:15 ` [ruby-core:106137] " Strech (Sergey Fedorov)
@ 2021-11-18 14:34 ` Eregon (Benoit Daloze)
14 siblings, 0 replies; 16+ messages in thread
From: Eregon (Benoit Daloze) @ 2021-11-18 14:34 UTC (permalink / raw
To: ruby-core
Issue #18287 has been updated by Eregon (Benoit Daloze).
@nobu In general, I think we should encourage external contributions.
In this case, you closed the original PR, https://github.com/ruby/ruby/pull/5079, when the discussion was not resolved,
and made your own PR (https://github.com/ruby/ruby/pull/5084) but I think nobody was aware of it until now (e.g., it's not linked here),
and so https://github.com/ruby/ruby/pull/5142 had to be closed as well.
I tried to ensure it was clear @Strech would work on this by setting the assignee and also he replied.
----------------------------------------
Feature #18287: Support nil value for sort in Dir.glob
https://bugs.ruby-lang.org/issues/18287#change-94746
* Author: Strech (Sergey Fedorov)
* Status: Closed
* Priority: Normal
* Assignee: Strech (Sergey Fedorov)
----------------------------------------
Good day, everyone.
I would like to suggest (or question) the support of a `nil` value for `sort` argument in `Dir.glob`.
I find this behaviour a bit surprising, here is an example:
```
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: true)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: false)
=> ["brace/a.js", "brace/a.js", "brace/a.html.erb", "brace/a.erb", "brace/a.js.rjs", "brace/a"]
irb(main):001:0> Dir.glob("brace/a{.js,*}", sort: nil)
=> ["brace/a.js", "brace/a", "brace/a.erb", "brace/a.html.erb", "brace/a.js", "brace/a.js.rjs"]
```
As you can see – `sort: nil` produces the same results as `sort: true` which is confusing
Github link: https://github.com/ruby/ruby/pull/5079
Ruby spec link: https://github.com/ruby/spec/pull/894
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-11-18 14:34 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04 8:47 [ruby-core:105928] [Ruby master Feature#18287] Support nil value for sort in Dir.glob Strech (Sergey Fedorov)
2021-11-04 9:17 ` [ruby-core:105929] " nobu (Nobuyoshi Nakada)
2021-11-04 9:22 ` [ruby-core:105930] " nobu (Nobuyoshi Nakada)
2021-11-04 11:32 ` [ruby-core:105932] " Eregon (Benoit Daloze)
2021-11-04 14:36 ` [ruby-core:105938] " jeremyevans0 (Jeremy Evans)
2021-11-05 18:38 ` [ruby-core:105949] " Eregon (Benoit Daloze)
2021-11-05 19:06 ` [ruby-core:105951] " jeremyevans0 (Jeremy Evans)
2021-11-06 1:24 ` [ruby-core:105952] " nobu (Nobuyoshi Nakada)
2021-11-06 12:19 ` [ruby-core:105960] " Eregon (Benoit Daloze)
2021-11-06 13:25 ` [ruby-core:105962] " Strech (Sergey Fedorov)
2021-11-18 6:17 ` [ruby-core:106118] " matz (Yukihiro Matsumoto)
2021-11-18 9:36 ` [ruby-core:106126] " Strech (Sergey Fedorov)
2021-11-18 9:37 ` [ruby-core:106127] " Eregon (Benoit Daloze)
2021-11-18 12:14 ` [ruby-core:106134] " Strech (Sergey Fedorov)
2021-11-18 13:15 ` [ruby-core:106137] " Strech (Sergey Fedorov)
2021-11-18 14:34 ` [ruby-core:106146] " Eregon (Benoit Daloze)
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).