ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: matz@ruby.or.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96877] [Ruby master Bug#16486] Hash.ruby2_keywords?(hash) and Hash.ruby2_keywords!(hash)
Date: Thu, 16 Jan 2020 04:28:31 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-83890.20200116042830.9254f073f76cd2de@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16486.20200106094637@ruby-lang.org

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


I propose

* Hash.ruby_keywords_hash(hash) to turn the flag on (non mutating)
* Hash.ruby_keywords_hash?(hash) to check the flag

Matz.

----------------------------------------
Bug #16486: Hash.ruby2_keywords?(hash) and Hash.ruby2_keywords!(hash)
https://bugs.ruby-lang.org/issues/16486#change-83890

* Author: mame (Yusuke Endoh)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: 
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED
----------------------------------------
Hash's ruby2_keywords flag is designed to be as implicit as possible, but unfortunately, sometimes we need to handle the flag explicitly.  In ActiveJob, the whole arguments are serialized and deserialized, and the process removes the flag; in this case, we need to check and save the flag when serializing, and restore the flag when deserializing.

https://github.com/rails/rails/pull/38105#discussion_r361863767

It is theoretically possible by [a very hacky code](https://gist.github.com/mame/18cd2dfc7d965d0bad1216f2fdd008ee#file-bouncing_test-patch-L117-L134), but it would be good to provide them officially.

https://github.com/ruby/ruby/pull/2818

* `Hash.ruby2_keywords?(hash)` checks if hash is flagged or not.
* `Hash.ruby2_keywords!(hash)` flags a given hash.

The reason why I don't add them as instance methods (`Hash#ruby2_keywords?`) is that they are never for casual use.  The ruby2_keywords flag will be removed after enough migration time.  Casual use of them will make it difficult to remove, so I'd like to keep them for non-casual use.

(I thought `RubyVM.ruby2_keywords?(hash)` is good but @eregon will be against it :-)

@jeremyevans0 Could you tell me your opinion?



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

      parent reply	other threads:[~2020-01-16  4:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-16486.20200106094637@ruby-lang.org>
2020-01-06  9:46 ` [ruby-core:96687] [Ruby master Feature#16486] Hash.ruby2_keywords?(hash) and Hash.ruby2_keywords!(hash) mame
2020-01-06 14:53 ` [ruby-core:96689] [Ruby master Bug#16486] " merch-redmine
2020-01-06 18:10 ` [ruby-core:96691] " eregontp
2020-01-06 23:27 ` [ruby-core:96696] " mame
2020-01-07 14:08 ` [ruby-core:96703] " daniel
2020-01-08 11:19 ` [ruby-core:96710] " eregontp
2020-01-08 23:53 ` [ruby-core:96722] " mame
2020-01-09 10:35 ` [ruby-core:96733] " eregontp
2020-01-14  6:27 ` [ruby-core:96835] " mame
2020-01-14  6:47 ` [ruby-core:96838] " mame
2020-01-16  4:28 ` matz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-83890.20200116042830.9254f073f76cd2de@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).