[#113407] [Ruby master Feature#19630] [RFC] Deprecate `Kernel.open("|command-here")` due to frequent security issues — "postmodern (Hal Brodigan) via ruby-core" <ruby-core@...>

Issue #19630 has been reported by postmodern (Hal Brodigan).

19 messages 2023/05/05

[#113430] [Ruby master Feature#19633] Allow passing block to `Kernel#autoload` as alternative to second `filename` argument — "shioyama (Chris Salzberg) via ruby-core" <ruby-core@...>

Issue #19633 has been reported by shioyama (Chris Salzberg).

16 messages 2023/05/09

[#113489] [Ruby master Bug#19642] Remove vectored read/write from `io.c`. — "ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>

Issue #19642 has been reported by ioquatix (Samuel Williams).

10 messages 2023/05/15

[#113498] [Ruby master Feature#19644] Module::current to complement Module::nesting — "bughit (bug hit) via ruby-core" <ruby-core@...>

Issue #19644 has been reported by bughit (bug hit).

12 messages 2023/05/16

[#113517] [Ruby master Misc#19679] Migrate Wiki from bugs.ruby-lang.org to ruby/ruby GitHub repository — "jemmai (Jemma Issroff) via ruby-core" <ruby-core@...>

Issue #19679 has been reported by jemmai (Jemma Issroff).

11 messages 2023/05/18

[#113529] [Ruby master Bug#19681] The final classpath of partially named modules is sometimes inconsistent once permanently named — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>

Issue #19681 has been reported by byroot (Jean Boussier).

34 messages 2023/05/19

[#113538] [Ruby master Feature#19682] ability to get a reference to the "default definee" — "bughit (bug hit) via ruby-core" <ruby-core@...>

Issue #19682 has been reported by bughit (bug hit).

28 messages 2023/05/19

[#113601] [Ruby master Bug#19687] Should a development version of the standard library be included in ruby/ruby? — "jaruga (Jun Aruga) via ruby-core" <ruby-core@...>

Issue #19687 has been reported by jaruga (Jun Aruga).

9 messages 2023/05/23

[#113632] [Ruby master Bug#19691] Case insensitive file systems, require filename casing — "MSP-Greg (Greg L) via ruby-core" <ruby-core@...>

Issue #19691 has been reported by MSP-Greg (Greg L).

7 messages 2023/05/24

[#113656] [Ruby master Misc#19693] Data initialization is significantly slower than Struct — janosch-x via ruby-core <ruby-core@...>

Issue #19693 has been reported by janosch-x (Janosch M=FCller).

13 messages 2023/05/25

[#113660] [Ruby master Feature#19694] Add Regexp#timeout= setter — "aharpole (Aaron Harpole) via ruby-core" <ruby-core@...>

Issue #19694 has been reported by aharpole (Aaron Harpole).

15 messages 2023/05/25

[#113676] [Ruby master Bug#19697] Resolv::DNS resolution for international domains fails with "Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT" — "clairity (claire c) via ruby-core" <ruby-core@...>

SXNzdWUgIzE5Njk3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGNsYWlyaXR5IChjbGFpcmUgYykuDQ0K

6 messages 2023/05/27

[ruby-core:113532] Re: [Ruby master Feature#19634] Pattern matching dynamic key

From: Austin Ziegler via ruby-core <ruby-core@...>
Date: 2023-05-19 15:59:03 UTC
List: ruby-core #113532
I count 44 instances of this in our production code (~100k lines of
Elixir), but I don=E2=80=99t think I=E2=80=99ve ever used key and value pin=
ning as shown in
the examples above.

But dynamic key matching is precisely what is required when it is required,
although it=E2=80=99s rare enough.

Here's a sample GraphQL response parser or the Shopify Customers API:

```elixir
  def parse_customer_response(%{} =3D body, resource, action) do
    gql_action =3D resource <> String.capitalize(action)

    case body do
      %{status: 200, body: %{^gql_action =3D> %{^resource =3D> %{} =3D resu=
lt,
"userErrors" =3D> []}}} ->
        {:ok, result}

      %{status: 200, body: %{^gql_action =3D> %{"userErrors" =3D> []} =3D
result}} ->
        {:ok, result}

      %{errors: errors} ->
        {:error, Enum.map(errors, &Map.get(&1, "message"))}

      %{body: %{^gql_action =3D> %{"userErrors" =3D> errors}}} ->
        {:error, Enum.map(errors, &Map.get(&1, "message"))}

      %{body: %{^gql_action =3D> nil}} ->
        {:error, [%{message: "#{gql_action} access denied"}]}

      %{body: nil} ->
        {:error, [%{message: "#{gql_action} access denied"}]}

      _ ->
        {:error, [%{message: "Unknown error"}]}
    end
  end
```

I haven=E2=80=99t started using pattern matching in Ruby, but I could see s=
ome
simplified code with dynamic key matching.

-a

On Thu, May 18, 2023 at 12:39=E2=80=AFAM marcandre (Marc-Andre Lafortune) v=
ia
ruby-core <ruby-core@ml.ruby-lang.org> wrote:

> Issue #19634 has been updated by marcandre (Marc-Andre Lafortune).
>
>
> Some actual examples of dynamic key matching in Elixir:
> https://github.com/search?q=3D%2F%25%5C%7B%5C%5E%2F+&type=3Dcode
>
> ----------------------------------------
> Feature #19634: Pattern matching dynamic key
> https://bugs.ruby-lang.org/issues/19634#change-103138
>
> * Author: baweaver (Brandon Weaver)
> * Status: Open
> * Priority: Normal
> ----------------------------------------
> I found myself in a situation ([stable marriage problem](
> https://rosettacode.org/wiki/Stable_marriage_problem#top-page)) where I
> would like to match against a dynamic key, like so:
>
> ```ruby
> mentor_proposals =3D { mentor_name: ['mentee_1', 'mentee_2'] }
> mentor_name =3D :mentor_name
> mentee_name =3D 'mentee_1'
>
> mentor_proposals in ^key: [*, ^mentee_name, *] # SyntaxError
> ```
>
> Currently this is not supported syntax, but there are some use cases in
> which I might see myself wanting to use it including this one. As
> `deconstruct_keys` currently accepts an `Array` of keys this would not
> break compatibility but would introduce syntactic complexity in capturing
> keys on hash-like matches.
>
> I believe the tradeoff is worthwhile, but would like to hear others
> opinions on the matter.
>
> Granted this case has some oddities of `Symbol` and `String`
> interchangeability as an implementation detail, and I will not be arguing
> for key irreverence in this issue as that's a [much more involved topic](
> https://dev.to/baweaver/the-case-for-pattern-matching-key-irreverence-in-=
ruby-1oll
> ).
>
>
>
> --
> https://bugs.ruby-lang.org/
>  ______________________________________________
>  ruby-core mailing list -- ruby-core@ml.ruby-lang.org
>  To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
>  ruby-core info --
> https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.=
org/
>


--=20
Austin Ziegler =E2=80=A2 halostatue@gmail.com =E2=80=A2 austin@halostatue.c=
a
http://www.halostatue.ca/ =E2=80=A2 http://twitter.com/halostatue
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

In This Thread