ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:63338] [ruby-trunk - Feature #9980] [Open] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
@ 2014-06-26 12:23 ` rr.rosas
  2014-06-26 12:27 ` [ruby-core:63339] [ruby-trunk - Feature #9980] " rr.rosas
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rr.rosas @ 2014-06-26 12:23 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been reported by Rodrigo Rosenfeld Rosas.

----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980

* Author: Rodrigo Rosenfeld Rosas
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~



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

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

* [ruby-core:63339] [ruby-trunk - Feature #9980] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
  2014-06-26 12:23 ` [ruby-core:63338] [ruby-trunk - Feature #9980] [Open] Create HashWithIndiferentAccess using new syntax {a: 1}i rr.rosas
@ 2014-06-26 12:27 ` rr.rosas
  2014-06-30  8:07 ` [ruby-core:63424] " naruse
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rr.rosas @ 2014-06-26 12:27 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been updated by Rodrigo Rosenfeld Rosas.

File feature-9980.pdf added

----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980#change-47386

* Author: Rodrigo Rosenfeld Rosas
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~

---Files--------------------------------
feature-9980.pdf (24.8 KB)


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

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

* [ruby-core:63424] [ruby-trunk - Feature #9980] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
  2014-06-26 12:23 ` [ruby-core:63338] [ruby-trunk - Feature #9980] [Open] Create HashWithIndiferentAccess using new syntax {a: 1}i rr.rosas
  2014-06-26 12:27 ` [ruby-core:63339] [ruby-trunk - Feature #9980] " rr.rosas
@ 2014-06-30  8:07 ` naruse
  2014-06-30 17:18 ` [ruby-core:63445] " rr.rosas
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: naruse @ 2014-06-30  8:07 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been updated by Yui NARUSE.


received, thanks!

----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980#change-47467

* Author: Rodrigo Rosenfeld Rosas
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~

---Files--------------------------------
feature-9980.pdf (24.8 KB)


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

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

* [ruby-core:63445] [ruby-trunk - Feature #9980] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-06-30  8:07 ` [ruby-core:63424] " naruse
@ 2014-06-30 17:18 ` rr.rosas
  2014-07-26  4:58 ` [ruby-core:64026] " naruse
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: rr.rosas @ 2014-06-30 17:18 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been updated by Rodrigo Rosenfeld Rosas.

File feature-9980.pdf added

Reattaching using Firefox

----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980#change-47487

* Author: Rodrigo Rosenfeld Rosas
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~

---Files--------------------------------
feature-9980.pdf (24.8 KB)
feature-9980.pdf (24.8 KB)


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

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

* [ruby-core:64026] [ruby-trunk - Feature #9980] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-06-30 17:18 ` [ruby-core:63445] " rr.rosas
@ 2014-07-26  4:58 ` naruse
  2014-07-26  5:12 ` [ruby-core:64028] [ruby-trunk - Feature #9980] [Rejected] " matz
  2014-07-28 12:56 ` [ruby-core:64097] [ruby-trunk - Feature #9980] " rr.rosas
  6 siblings, 0 replies; 7+ messages in thread
From: naruse @ 2014-07-26  4:58 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been updated by Yui NARUSE.

File deleted (feature-9980.pdf)

----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980#change-48039

* Author: Rodrigo Rosenfeld Rosas
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~

---Files--------------------------------
feature-9980.pdf (24.8 KB)


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

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

* [ruby-core:64028] [ruby-trunk - Feature #9980] [Rejected] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-07-26  4:58 ` [ruby-core:64026] " naruse
@ 2014-07-26  5:12 ` matz
  2014-07-28 12:56 ` [ruby-core:64097] [ruby-trunk - Feature #9980] " rr.rosas
  6 siblings, 0 replies; 7+ messages in thread
From: matz @ 2014-07-26  5:12 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been updated by Yukihiro Matsumoto.

Status changed from Open to Rejected

Suffix `i` is used for complex (imaginary) numbers. It's bit confusing.
Maybe what you want can be gained by shorter/nicer name for Hash#compare_by_identity.

Matz.


----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980#change-48041

* Author: Rodrigo Rosenfeld Rosas
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~

---Files--------------------------------
feature-9980.pdf (24.8 KB)


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

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

* [ruby-core:64097] [ruby-trunk - Feature #9980] Create HashWithIndiferentAccess using new syntax {a: 1}i
       [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-07-26  5:12 ` [ruby-core:64028] [ruby-trunk - Feature #9980] [Rejected] " matz
@ 2014-07-28 12:56 ` rr.rosas
  6 siblings, 0 replies; 7+ messages in thread
From: rr.rosas @ 2014-07-28 12:56 UTC (permalink / raw
  To: ruby-core

Issue #9980 has been updated by Rodrigo Rosenfeld Rosas.


Was this rejected because the i suffix was already taken or because the idea of using suffixes would be confusing? Should I try another suffix in another ticket?

I don't think compare_by_identity does what I want. It seems to behave similar to ActiveSupport Hash#symbolize_keys which is different from Hash#with_indifferent_access which is what I really want.

I don't want to have to worry if I should call hash[:a] or hash['a']. Also compare_by_identity is a bad feature to me as it modifies the way the original hash works (it should be called compare_by_identity! in my opinion) and you can't undo its effect.

Maybe Ruby core could provide some utility to return a HWIA from a hash, like H(a: 1) meaning an equivalent of HWIA.new(a: 1).

----------------------------------------
Feature #9980: Create HashWithIndiferentAccess using new syntax {a: 1}i
https://bugs.ruby-lang.org/issues/9980#change-48109

* Author: Rodrigo Rosenfeld Rosas
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: current: 2.2.0
----------------------------------------
This is related to feature #7797. For that feature I requested a regular hash ({}) to be treated as HWIA and the current hash implementation would be available as StrictHash.new since it's not as much needed as the common case of expecting a[:a] to be the same as a['a'].

Although I still prefer the proposal in #7797, I'd like to propose an alternative syntax for a new implementation of Hash that converts symbols to strings in keys (or keys to strings, it doesn't matter). This:

~~~
{my_key: 'my_value'}i
~~~

Should be equivalent to:

~~~
HashWithIndifferentAccess.new(my_key: 'my_value') # from ActiveSupport
~~~

It doesn't have to behave exactly like the implementation from ActiveSupport. I only really care about symbols and strings being treated the same way.

This is not as great as #7797 because it will only affect user's own code rather than hashes created by other libraries (unless they decide to adopt the new syntax, which could take quite a while to keep backward compatibility with old Ruby versions). But it would already make it way more pleasant to define new hashes with indifferent access.

Maybe it could act recursively during the hash creation, but I'm fine if you think it would be more confusing than helpful. To illustrate:

~~~
{a: {b: 1}}i
~~~

could mean the same as:

~~~
{a: {b: 1}i}i
~~~

---Files--------------------------------
feature-9980.pdf (24.8 KB)


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

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

end of thread, other threads:[~2014-07-28 13:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9980.20140626122334@ruby-lang.org>
2014-06-26 12:23 ` [ruby-core:63338] [ruby-trunk - Feature #9980] [Open] Create HashWithIndiferentAccess using new syntax {a: 1}i rr.rosas
2014-06-26 12:27 ` [ruby-core:63339] [ruby-trunk - Feature #9980] " rr.rosas
2014-06-30  8:07 ` [ruby-core:63424] " naruse
2014-06-30 17:18 ` [ruby-core:63445] " rr.rosas
2014-07-26  4:58 ` [ruby-core:64026] " naruse
2014-07-26  5:12 ` [ruby-core:64028] [ruby-trunk - Feature #9980] [Rejected] " matz
2014-07-28 12:56 ` [ruby-core:64097] [ruby-trunk - Feature #9980] " rr.rosas

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).