ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:60112] [ruby-trunk - Feature #9453] [Open] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
@ 2014-01-26 17:55 ` jballanc
  2014-02-03 15:05 ` [ruby-core:60425] [ruby-trunk - Feature #9453] " jballanc
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jballanc @ 2014-01-26 17:55 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been reported by Joshua Ballanco.

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:60425] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
  2014-01-26 17:55 ` [ruby-core:60112] [ruby-trunk - Feature #9453] [Open] Return symbols of defined methods for `attr` and friends jballanc
@ 2014-02-03 15:05 ` jballanc
  2014-02-03 15:13 ` [ruby-core:60426] " eregontp
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jballanc @ 2014-02-03 15:05 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Joshua Ballanco.


*bump*

Would be nice if we could get this in 2.2 (if someone could update the target version, I'd appreciate it).

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-44896

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:60426] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
  2014-01-26 17:55 ` [ruby-core:60112] [ruby-trunk - Feature #9453] [Open] Return symbols of defined methods for `attr` and friends jballanc
  2014-02-03 15:05 ` [ruby-core:60425] [ruby-trunk - Feature #9453] " jballanc
@ 2014-02-03 15:13 ` eregontp
  2014-02-03 18:44 ` [ruby-core:60428] " sawadatsuyoshi
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: eregontp @ 2014-02-03 15:13 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Benoit Daloze.


    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

does not look so nice to me (the parens and the explicit splat).
Maybe #private should accept an Array of Symbols so:

    private attr_reader :images, :key_map, :window, :screen_manager, :animations

If there are so much ":", it might also be worth using %i:

    private attr_reader %i[images key_map window screen_manager animations]

but then attr_reader would also need to accept an Array of Symbols.

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-44897

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:60428] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-02-03 15:13 ` [ruby-core:60426] " eregontp
@ 2014-02-03 18:44 ` sawadatsuyoshi
  2014-02-04  5:12   ` [ruby-core:60440] " Avdi Grimm
  2014-02-04  5:22 ` [ruby-core:60441] " avdi
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 15+ messages in thread
From: sawadatsuyoshi @ 2014-02-03 18:44 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Tsuyoshi Sawada.


What is the point of defining a private accessor method? You can directly refer to the instance variables without using accessors.

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-44898

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:60440] Re: [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
  2014-02-03 18:44 ` [ruby-core:60428] " sawadatsuyoshi
@ 2014-02-04  5:12   ` Avdi Grimm
  0 siblings, 0 replies; 15+ messages in thread
From: Avdi Grimm @ 2014-02-04  5:12 UTC (permalink / raw
  To: Ruby developers

[-- Attachment #1: Type: text/plain, Size: 2165 bytes --]

There are a number of reasons I use them, but the most obvious is that a
misspelled accessor method will raise NoMethod error, whereas a misspelled
@ivar reference will silently return nil.



On Mon, Feb 3, 2014 at 1:44 PM, <sawadatsuyoshi@gmail.com> wrote:

> Issue #9453 has been updated by Tsuyoshi Sawada.
>
>
> What is the point of defining a private accessor method? You can directly
> refer to the instance variables without using accessors.
>
> ----------------------------------------
> Feature #9453: Return symbols of defined methods for `attr` and friends
> https://bugs.ruby-lang.org/issues/9453#change-44898
>
> * Author: Joshua Ballanco
> * Status: Open
> * Priority: Normal
> * Assignee:
> * Category: core
> * Target version:
> ----------------------------------------
> With Ruby 2.1 returning a symbol from `def` and `define_method`, that
> leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to
> define methods that still return nil. This is unfortunate, because it
> prevents the use of method decorators developed to work with `def` from
> also working with the `attr*` methods. Because these mechanisms can define
> more than one method, the return values would need to be arrays of symbols.
>
> For an example of how this could be useful in real-world code, consider
> this sample from James Edward Gray II's Warehouse Keeper example (
> https://github.com/JEG2/warehouse_keeper):
>
>     attr_reader :images, :key_map, :window, :screen_manager, :animations
>     private     :images, :key_map, :window, :screen_manager, :animations
>
> if `attr_reader` returned symbols, then this could be simplified to:
>
>     private *attr_reader(:images, :key_map, :window, :screen_manager,
> :animations)
>
> I've attached a patch that implements this change and includes a few
> tests. For those who use git, I've also submitted this as a pull request
> here: https://github.com/ruby/ruby/pull/517
>
> ---Files--------------------------------
> attr_rv.patch (3.23 KB)
>
>
> --
> http://bugs.ruby-lang.org/
>



-- 
Avdi Grimm
http://avdi.org

I only check email twice a day. to reach me sooner, go to
http://awayfind.com/avdi

[-- Attachment #2: Type: text/html, Size: 3096 bytes --]

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

* [ruby-core:60441] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-02-03 18:44 ` [ruby-core:60428] " sawadatsuyoshi
@ 2014-02-04  5:22 ` avdi
  2014-02-05  0:27 ` [ruby-core:60454] " jballanc
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: avdi @ 2014-02-04  5:22 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Avdi Grimm.


 There are a number of reasons I use them, but the most obvious is that a
 misspelled accessor method will raise NoMethod error, whereas a misspelled
 @ivar reference will silently return nil.
 
 
 
 On Mon, Feb 3, 2014 at 1:44 PM, <sawadatsuyoshi@gmail.com> wrote:
 
 > Issue #9453 has been updated by Tsuyoshi Sawada.
 >
 >
 > What is the point of defining a private accessor method? You can directly
 > refer to the instance variables without using accessors.
 >
 > ----------------------------------------
 > Feature #9453: Return symbols of defined methods for `attr` and friends
 > https://bugs.ruby-lang.org/issues/9453#change-44898
 >
 > * Author: Joshua Ballanco
 > * Status: Open
 > * Priority: Normal
 > * Assignee:
 > * Category: core
 > * Target version:
 > ----------------------------------------
 > With Ruby 2.1 returning a symbol from `def` and `define_method`, that
 > leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to
 > define methods that still return nil. This is unfortunate, because it
 > prevents the use of method decorators developed to work with `def` from
 > also working with the `attr*` methods. Because these mechanisms can define
 > more than one method, the return values would need to be arrays of symbols.
 >
 > For an example of how this could be useful in real-world code, consider
 > this sample from James Edward Gray II's Warehouse Keeper example (
 > https://github.com/JEG2/warehouse_keeper):
 >
 >     attr_reader :images, :key_map, :window, :screen_manager, :animations
 >     private     :images, :key_map, :window, :screen_manager, :animations
 >
 > if `attr_reader` returned symbols, then this could be simplified to:
 >
 >     private *attr_reader(:images, :key_map, :window, :screen_manager,
 > :animations)
 >
 > I've attached a patch that implements this change and includes a few
 > tests. For those who use git, I've also submitted this as a pull request
 > here: https://github.com/ruby/ruby/pull/517
 >
 > ---Files--------------------------------
 > attr_rv.patch (3.23 KB)
 >
 >
 > --
 > http://bugs.ruby-lang.org/
 >
 
 
 
 -- 
 Avdi Grimm
 http://avdi.org
 
 I only check email twice a day. to reach me sooner, go to
 http://awayfind.com/avdi

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-44905

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:60454] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-02-04  5:22 ` [ruby-core:60441] " avdi
@ 2014-02-05  0:27 ` jballanc
  2014-03-27 17:13 ` [ruby-core:61726] " jballanc
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jballanc @ 2014-02-05  0:27 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Joshua Ballanco.


Tsuyoshi Sawada wrote:
> What is the point of defining a private accessor method? You can directly refer to the instance variables without using accessors.

The example I gave was just one case of "code in the wild" that would benefit from this change. Undoubtedly, as more people begin to take advantage of the ability to build method decorators (now that method definitions return something other than `nil`), having the attr* family of methods return something meaningful will mean that they can also benefit from these decorators.


----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-44914

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:61726] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-02-05  0:27 ` [ruby-core:60454] " jballanc
@ 2014-03-27 17:13 ` jballanc
  2014-03-28 15:55 ` [ruby-core:61741] [ruby-trunk - Feature #9453] [Assigned] " usa
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jballanc @ 2014-03-27 17:13 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Joshua Ballanco.


It's been almost 2 months...any chance we could get a comment on this from the core team?

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-45966

* Author: Joshua Ballanco
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:61741] [ruby-trunk - Feature #9453] [Assigned] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-03-27 17:13 ` [ruby-core:61726] " jballanc
@ 2014-03-28 15:55 ` usa
  2014-03-29 14:58 ` [ruby-core:61753] [ruby-trunk - Feature #9453] [Rejected] " matz
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: usa @ 2014-03-28 15:55 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Usaku NAKAMURA.

Status changed from Open to Assigned
Assignee set to Yukihiro Matsumoto

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-45981

* Author: Joshua Ballanco
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:61753] [ruby-trunk - Feature #9453] [Rejected] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-03-28 15:55 ` [ruby-core:61741] [ruby-trunk - Feature #9453] [Assigned] " usa
@ 2014-03-29 14:58 ` matz
  2014-04-11 19:48 ` [ruby-core:61995] [ruby-trunk - Feature #9453] " transfire
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: matz @ 2014-03-29 14:58 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Yukihiro Matsumoto.

Status changed from Assigned to Rejected

I am not positive.  The example

  private *attr_reader(:images, :key_map, :window, :screen_manager,:animations)

is not really intuitive.  Besides that, you can define private_attr_reader, etc. by yourself.
In that case, the code will be

  private_attr_reader :images, :key_map, :window, :screen_manager,:animations

and looks much better.

Matz

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-45991

* Author: Joshua Ballanco
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:61995] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-03-29 14:58 ` [ruby-core:61753] [ruby-trunk - Feature #9453] [Rejected] " matz
@ 2014-04-11 19:48 ` transfire
  2014-04-12  1:31 ` [ruby-core:61997] " matz
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: transfire @ 2014-04-11 19:48 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Thomas Sawyer.


Letting #private accept an Array seems more preferable then adding yet another ~~method~~ slew of methods: `private_attr_writer`, `private_attr_accessor`, `protected_attr_reader`, `protected_attr_writer`, `protected_attr_accessor`, ...



----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-46186

* Author: Joshua Ballanco
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:61997] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-04-11 19:48 ` [ruby-core:61995] [ruby-trunk - Feature #9453] " transfire
@ 2014-04-12  1:31 ` matz
  2014-08-08 22:38 ` [ruby-core:64276] " nerdrew
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: matz @ 2014-04-12  1:31 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Yukihiro Matsumoto.


Thomas, private method that accept an array for methods names would be an interesting idea worth discussion.
But it is different issue.

Matz.


----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-46188

* Author: Joshua Ballanco
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:64276] [ruby-trunk - Feature #9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2014-04-12  1:31 ` [ruby-core:61997] " matz
@ 2014-08-08 22:38 ` nerdrew
  2017-03-11  5:43 ` [ruby-core:80009] [Ruby trunk Feature#9453] " vsalikhov
  2017-04-17  8:29 ` [ruby-core:80732] " matz
  13 siblings, 0 replies; 15+ messages in thread
From: nerdrew @ 2014-08-08 22:38 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Andrew Lazarus.


Chaining the two suggestions leads to a nice syntax (in my opinion):

`private attr_reader :name, :address, :etc`

`private` needs to accept an array and `attr_*` needs to return its list (as an array) of arguments.

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-48263

* Author: Joshua Ballanco
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:80009] [Ruby trunk Feature#9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2014-08-08 22:38 ` [ruby-core:64276] " nerdrew
@ 2017-03-11  5:43 ` vsalikhov
  2017-04-17  8:29 ` [ruby-core:80732] " matz
  13 siblings, 0 replies; 15+ messages in thread
From: vsalikhov @ 2017-03-11  5:43 UTC (permalink / raw
  To: ruby-core

Issue #9453 has been updated by Vais Salikhov.


`attr_*` methods returning `nil` should be considered a bug at this point, since all other ways of defining methods return a symbol. This makes Ruby inconsistent, and violates its own Principle of Least Surprise.

----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-63426

* Author: Joshua Ballanco
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

* [ruby-core:80732] [Ruby trunk Feature#9453] Return symbols of defined methods for `attr` and friends
       [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2017-03-11  5:43 ` [ruby-core:80009] [Ruby trunk Feature#9453] " vsalikhov
@ 2017-04-17  8:29 ` matz
  13 siblings, 0 replies; 15+ messages in thread
From: matz @ 2017-04-17  8:29 UTC (permalink / raw
  To: ruby-core

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


Yes, `def` and `define_method` returns symbols now.
But it does not mean `attr_*` should return symbols. Since they can define multiple methods.
Considering there's no use for private attributes, I don't think the proposal creates real-world value.

Besides that, mention to the principle of least surprise gives you negative evaluation here (since the background varies from user to user, and it does not lead to constructive discussion).

Matz.


----------------------------------------
Feature #9453: Return symbols of defined methods for `attr` and friends
https://bugs.ruby-lang.org/issues/9453#change-64287

* Author: jballanc (Joshua Ballanco)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
With Ruby 2.1 returning a symbol from `def` and `define_method`, that leaves `attr`, `attr_reader`, `attr_writer`, and `attr_accessor` as ways to define methods that still return nil. This is unfortunate, because it prevents the use of method decorators developed to work with `def` from also working with the `attr*` methods. Because these mechanisms can define more than one method, the return values would need to be arrays of symbols.

For an example of how this could be useful in real-world code, consider this sample from James Edward Gray II's Warehouse Keeper example (https://github.com/JEG2/warehouse_keeper):

    attr_reader :images, :key_map, :window, :screen_manager, :animations
    private     :images, :key_map, :window, :screen_manager, :animations

if `attr_reader` returned symbols, then this could be simplified to:

    private *attr_reader(:images, :key_map, :window, :screen_manager, :animations)

I've attached a patch that implements this change and includes a few tests. For those who use git, I've also submitted this as a pull request here: https://github.com/ruby/ruby/pull/517

---Files--------------------------------
attr_rv.patch (3.23 KB)


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

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

end of thread, other threads:[~2017-04-17  7:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9453.20140126175558@ruby-lang.org>
2014-01-26 17:55 ` [ruby-core:60112] [ruby-trunk - Feature #9453] [Open] Return symbols of defined methods for `attr` and friends jballanc
2014-02-03 15:05 ` [ruby-core:60425] [ruby-trunk - Feature #9453] " jballanc
2014-02-03 15:13 ` [ruby-core:60426] " eregontp
2014-02-03 18:44 ` [ruby-core:60428] " sawadatsuyoshi
2014-02-04  5:12   ` [ruby-core:60440] " Avdi Grimm
2014-02-04  5:22 ` [ruby-core:60441] " avdi
2014-02-05  0:27 ` [ruby-core:60454] " jballanc
2014-03-27 17:13 ` [ruby-core:61726] " jballanc
2014-03-28 15:55 ` [ruby-core:61741] [ruby-trunk - Feature #9453] [Assigned] " usa
2014-03-29 14:58 ` [ruby-core:61753] [ruby-trunk - Feature #9453] [Rejected] " matz
2014-04-11 19:48 ` [ruby-core:61995] [ruby-trunk - Feature #9453] " transfire
2014-04-12  1:31 ` [ruby-core:61997] " matz
2014-08-08 22:38 ` [ruby-core:64276] " nerdrew
2017-03-11  5:43 ` [ruby-core:80009] [Ruby trunk Feature#9453] " vsalikhov
2017-04-17  8:29 ` [ruby-core:80732] " matz

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