> No.  Using !x explicitly disallows the method call in context x, even if
> there is class one, or an AUTOLOAD, or a superclass one.  The idea is that
> you can specify !r, and avoid the expensive fallbacks.

This just plain seems ludicrous to me. This definitely isn't something
having to do with autoaccessors. Why limit this to hash autoaccessors?

What you're talking about is saying "no AutoLoader" in a way. There's
too many things being conflated here. Saying "don't search for this
method" has nothing todo with autoaccessors. This is a separate issue
from accessors and warrants a separate RFC. Perhaps a separate keyword
'nosearch' that could be tagged onto subs, vars, etc, etc.
 
> > I don't see why you'd want to restrict l/r sides if they're hash keys.
> > This is implicit in making them readonly.
>
> Making them readonly makes all hash writes fail on them.  This is only for
> the autoaccessor.  And remember, ~w just makes the autoaccessor not exist
> for lvalue contexts of the autoaccessor.  It doesn't impede a normal sub,
> nor _explicit hash access_.

Ok, I see what you're getting at with this. You're claiming that you
could have an rvalue sub be an autoaccessor, but the lvalue sub be a
real sub? This makes sense, I hadn't thought of this particular
combination.

> > That is a lot simpler and seems to feel a lot better.
> I quite agree, and I'd rather have some cleaner way of specifing stuff like
> this

Let me propose a different approach then. We already have lvalue and
rvalue for subs, why not "laccess" and "raccess":

   $self->{name} : laccess = "Nate";
   $self->{peers} : raccess = [ "Jim", "Bob" ];

I think everything you're talking about (except !, but see above) comes
down to either left-side access ("laccess") or right-side access
("raccess"). This has the nice benefit of making it parallel to subs,
and only affects the autoaccessor (vs. :constant).

These two keywords would have the following properties:

   laccess - lvalue access, writeable, rvalue sub doesn't exist
   raccess - rvalue access, readonly, lvalue sub doesn't exist

If you wanted to specify both, just combine the two:

   $self->{name} : laccess = "Nate";
   $self->{peers} : raccess, laccess = [ "Jim", "Bob" ];

That makes it really obvious what's going on.
 
> >      $self->{CONFIG}->{DEFAULT_DIR} : access, constant = '/usr/bin';
> >      $self->{STATE}->{DEFAULT_DIR} : access;  # "sub redefined" warning
> 
> I've got only one idea of how to do this well, and you aren't going to like
> it...  A deref attribute, which always dereferences the key's value.
> That way, you'd make
> $self->{name} :accessable(':deref') = \$self->{STATE}->{name};

I'll think some more on this and see if I can come up with anything.

-Nate

Reply via email to