Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 66554
Status: open
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: mjd [...] icgroup.com
Cc: mjd [...] plover.com
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: mjd [...] plover.com
Subject: Can't turn 'ro' attribute into 'rw' attribute in class
Date: Fri, 11 Mar 2011 14:41:46 -0500
To: bug-moose [...] rt.cpan.org
From: Mark Jason Dominus <mjd [...] icgroup.com>
The attached program "bug", when run with Moose 1.19 and Moose::Role 1.19, says: Cannot assign a value to a read-only accessor at bug line 2 It should exit successfully without printing anything.
Download bug-report.tgz
application/x-compressed-tar 327b

Message body not shown because it is not plain text.

On Fri Mar 11 14:42:24 2011, mjd@icgroup.com wrote: Show quoted text
> The attached program "bug", when run with Moose 1.19 and Moose::Role > 1.19, says: > > Cannot assign a value to a read-only accessor at bug line 2 > > It should exit successfully without printing anything.
No, it shouldn't; the documentation lists things that are allowed to be overridden using "has '+attr'", and 'is' isn't one of them. It should probably die instead.
From: Mark Dominus
On Fri Mar 11 14:46:20 2011, HDP wrote: Show quoted text
> No, it shouldn't; the documentation lists things that are allowed to
be Show quoted text
> overridden using "has '+attr'", and 'is' isn't one of them. It should > probably die instead.
That would also be acceptable, and I see that it is documented as such in the Moose manual. But yesterday doy said: Mar 10 15:03:05 <doy> so your case should work Mar 10 15:04:43 <doy> if i remember correctly, the intention of the current logic is "you're allowed to override anything, as long as you don't change the name of a method that was already generated in a superclass" It would also make sense to me to allow overriding a rw attribute to ro, but not the other way around.
Subject: Re: [rt.cpan.org #66554] Can't turn 'ro' attribute into 'rw' attribute in class
Date: Fri, 11 Mar 2011 15:04:17 -0500
To: bug-Moose [...] rt.cpan.org
From: Stevan Little <stevan.little [...] iinteractive.com>
On Mar 11, 2011, at 2:52 PM, http://mjdominus.myopenid.com/ via RT wrote: Show quoted text
> Queue: Moose > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=66554 > > > On Fri Mar 11 14:46:20 2011, HDP wrote:
>> No, it shouldn't; the documentation lists things that are allowed to
> be
>> overridden using "has '+attr'", and 'is' isn't one of them. It should >> probably die instead.
> > That would also be acceptable, and I see that it is documented as such > in the Moose manual. But yesterday doy said: > > > Mar 10 15:03:05 <doy> so your case should work > Mar 10 15:04:43 <doy> if i remember correctly, the intention of the > current logic is "you're allowed to override anything, as long as you > don't change the name of a method that was already generated in a > superclass" > > > It would also make sense to me to allow overriding a rw attribute to ro, > but not the other way around. >
I think the reason 'is' is not override-able probably has something to do with the fact it is really not a true attribute of the attribute meta-object, and instead is expanded into reader/writer/accessor at attribute meta-object construction time. Perhaps a better solution would be for you to either provide an 'accessor' in the +attr or a 'writer' with a different name. I tend to agree with Dieter as well, it should die. - Stevan
Subject: Re: [rt.cpan.org #66554] Can't turn 'ro' attribute into 'rw' attribute in class
Date: Fri, 11 Mar 2011 14:15:33 -0600
To: Stevan Little via RT <bug-Moose [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
On Fri, Mar 11, 2011 at 03:04:30PM -0500, Stevan Little via RT wrote: Show quoted text
> Queue: Moose > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=66554 > > > > On Mar 11, 2011, at 2:52 PM, http://mjdominus.myopenid.com/ via RT wrote: >
> > Queue: Moose > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=66554 > > > > > On Fri Mar 11 14:46:20 2011, HDP wrote:
> >> No, it shouldn't; the documentation lists things that are allowed to
> > be
> >> overridden using "has '+attr'", and 'is' isn't one of them. It should > >> probably die instead.
> > > > That would also be acceptable, and I see that it is documented as such > > in the Moose manual. But yesterday doy said: > > > > > > Mar 10 15:03:05 <doy> so your case should work > > Mar 10 15:04:43 <doy> if i remember correctly, the intention of the > > current logic is "you're allowed to override anything, as long as you > > don't change the name of a method that was already generated in a > > superclass" > > > > > > It would also make sense to me to allow overriding a rw attribute to ro, > > but not the other way around. > >
> > I think the reason 'is' is not override-able probably has something to do with the fact it is really not a true attribute of the attribute meta-object, and instead is expanded into reader/writer/accessor at attribute meta-object construction time. > > Perhaps a better solution would be for you to either provide an 'accessor' in the +attr or a 'writer' with a different name.
I tested this too - "has '+foo' => (accessor => 'foo')" is also broken. Not entirely sure why. Show quoted text
> I tend to agree with Dieter as well, it should die.
I don't... it's not like you couldn't manually override the reader with a hand written accessor in a subclass, and it's not like you're going to accidentally use "has '+foo'".
From: Mark Dominus
I only posted this to make Sartak happy.
Subject: Re: [rt.cpan.org #66554] Can't turn 'ro' attribute into 'rw' attribute in class
Date: Fri, 11 Mar 2011 15:35:20 -0500
To: bug-Moose [...] rt.cpan.org
From: Shawn M Moore <sartak [...] gmail.com>
(11/03/11 14:52), http://mjdominus.myopenid.com/ via RT wrote: Show quoted text
> Queue: Moose > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=66554> > > On Fri Mar 11 14:46:20 2011, HDP wrote:
>> No, it shouldn't; the documentation lists things that are allowed to
> be
>> overridden using "has '+attr'", and 'is' isn't one of them. It should >> probably die instead.
> > That would also be acceptable, and I see that it is documented as such > in the Moose manual. But yesterday doy said: > > > Mar 10 15:03:05<doy> so your case should work > Mar 10 15:04:43<doy> if i remember correctly, the intention of the > current logic is "you're allowed to override anything, as long as you > don't change the name of a method that was already generated in a > superclass" > > > It would also make sense to me to allow overriding a rw attribute to ro, > but not the other way around.
It depends on what the definition of "is" is. Allowing you to change "is" in either direction lets you violates Liskov. Which Moose certainly lets you do, in the spirit of the rest of Perl. Regardless of what the underlying implementation of "is" is doing, I think we should allow you to both "has '+foo' => (is => 'ro')" *and* "has '+foo' => (is => 'rw')". Shawn
From: Mark Dominnus
Show quoted text
> It depends on what the definition of "is" is.
Sure. As I said, I would be happy with any of several reasonable behaviors. It seems from this thread that everyone agrees that the current behavior is unreasonable. P.S.: Note openid.