Re: lvaluable AUTOLOAD (help! Abigail! someone!)
- From: Darin McBride <dmcbride@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 06 May 2008 13:55:28 GMT
Dodger wrote:
So it seemed that with all the things Perl can do I should have been
able to do the same thing in Perl, right? Maybe with a little
finagling, but it hsould be possible.
Take a look at Contextual::Return. It may provide enough syntactical sugar
to make this easy.
Rough guess, untested:
sub _any(&@) { my $s = shift; $s->() && return 1 for @_; return; }
sub AUTOLOAD :lvalue {
my $self = shift;
my ($property) = $AUTOLOAD) =~ /::([^:]+)$/;
if (_any { $property eq $_ }, @{$self->{_vars}{protected}}) {
return RVALUE { $self->{$property} }
LVALUE { require Carp; croak "Can't use $property as lvalue" }
}
$self->{$property}
}
Or something like that.
.
- References:
- lvaluable AUTOLOAD (help! Abigail! someone!)
- From: Dodger
- lvaluable AUTOLOAD (help! Abigail! someone!)
- Prev by Date: Re: lvaluable AUTOLOAD (help! Abigail! someone!)
- Next by Date: Re: Perl Module using XS
- Previous by thread: Re: lvaluable AUTOLOAD (help! Abigail! someone!)
- Index(es):