in reply to Re^3: Psychic Disconnect and Object Systems
in thread Psychic Disconnect and Object Systems

No you don't. You get an error.
Here we go... Which error? Well, let's look at the docs...
has $name|@$names => %options

This will install an attribute of a given $name into the current class. If the first parameter is an array reference, it will create an attribute for every $name in the list. The %options are the same as those provided by Class::MOP::Attribute, in addition to the list below which are provided by Moose (Moose::Meta::Attribute to be more specific):

is => 'rw'|'ro'

The is option accepts either rw (for read/write) or ro (for read only). These will create either a read/write accessor or a read-only accessor respectively, using the same name as the $name of the attribute.

If you need more control over how your accessors are named, you can use the reader, writer and accessor options inherited from Class::MOP::Attribute, however if you use those, you won't need the is option.

Looks like "has" takes a scalar and a hash of options, and "is" doesn't seem to be a mandatory option. You've got me stumped!
  • Comment on Re^4: Psychic Disconnect and Object Systems

Replies are listed 'Best First'.
Re^5: Psychic Disconnect and Object Systems
by ikegami (Patriarch) on Apr 15, 2011 at 22:47 UTC

    "Attribute (%s) of class %s has no associated methods (did you mean to provide an "is" argument?)"

    Basically, omitting "is" (or equivalent) doesn't make the attribute read-only, it makes it neither readable nor writable!

    and "is" doesn't seem to be a mandatory option

    Remember how I said is is just a shortcut for something else? It's the lack of getters that actually triggers the error.

Re^5: Psychic Disconnect and Object Systems
by ikegami (Patriarch) on Apr 15, 2011 at 22:52 UTC

    "Attribute (%s) of class %s has no associated methods (did you mean to provide an "is" argument?)"

    Basically, omitting "is" (or equivalent) doesn't make the attribute read-only, it makes it neither readable nor writable!

    and "is" doesn't seem to be a mandatory option

    Remember how I said is is just a shortcut for something else? It's the lack of getters that actually triggers the error.