On Wed, Mar 30, 2011 at 1:23 PM, Matt S Trout <dbix-cl...@trout.me.uk>wrote:

> On 30/03/11 20:20, Chris Weyl wrote:
>
>> On Mon, Mar 28, 2011 at 6:22 AM, Stevan Little<
>> stevan.lit...@iinteractive.com>  wrote:
>>
>>
>>> On Mar 28, 2011, at 8:28 AM, Peter Gordon wrote:
>>>
>>>  I have a small class, where I would like the variables to be read only
>>>> by external calls, but rw for internal access.
>>>>
>>>
>>> has 'foo' =>  ( is =>  'ro', writer =>  '_set_foo', ... );
>>>
>>> Is the more common method for this.
>>>
>>
>>
>> On a related note, I actually found myself using that construction
>> frequently enough that I finally put together an attribute trait to take
>> "is
>> =>  'rwp'" (read-write-private) which then sets "is =>  'ro', writer =>
>> '_$name'".  It's on the CPAN at MooseX::AttributeShortcuts... The next
>> version is likely to be parameterizable, so '_set_$name' could be the
>> generated writer name.
>>
>
> _set_$name is the convention pretty much everywhere I see it done so that
> should be the default.
>

I'm a little disinclined to make this change as I've already published the
package to the CPAN.  It's only a couple days old though, so if this is The
Way It Should Be I can get over that :)


> It'd also be nice if you could steal Moo's is => 'lazy' shortcut since I'd
> like that to work for people doing Moose stuff as well in order to be able
> to de-experimental it since it's rather nicer than lazy_build
>

No problem.  I hadn't seen that before, but it certainly looks like a
reasonable shortcut to me.

                               -Chris

-- 
Chris Weyl
Ex astris scientia

Reply via email to