I don't need to return a constant under any circumstance, but if I
know I am returning an rvalue, I can return:
p->{_path}
If something is being assigned to 'path', then I'd know I need the
lvalue -- and return something like
$p->{tied_path}
sub callback_for_STORE_into_tied_path { my $p=shift;
my $newvalue;
$p->{_path}=$newvalue;
$p->{_url}=undef;
...
$p->{_path};
}
...later...in
sub url(;$) { my $p=shift;
$p->compose_url_from_parts() unless defined $p->{_url};
$p->{_url}
}
So if someone want to read path, they would get a simple, direct reference (no tied var overhead), but if they wrote to it, it
needs to store the new value, and clear the internal value for _url
so it can be re-composed.
At no point should I need to return a constant -- just a choice
between the actual var in the hash, or a tied var.
If I knew the lvalue-context, is there a reason why that wouldn't work?