[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: GdkRectangle, again
- From: Chas Owens <alas wilma widomaker com>
- To: muppet <scott asofyet org>
- Cc: gtk-perl-list gnome org
- Subject: Re: GdkRectangle, again
- Date: Tue, 29 Apr 2003 12:06:29 -0400 (EDT)
On Tue, 29 Apr 2003, muppet wrote:
>
> Chas Owens said:
> > sub get : lvalue {
>
> wow, that's really handy! unfortunately, the docs say it's still
> experimental. can we trust it not to change? [i got burned on the threading
> stuff...]
>
> --
> muppet <scott at asofyet dot org>
>
No, it has already changed to "is rw" in Apocalypse 6, but you should be able to continue using " : lvalue " for the rest of Perl 5's life.
<snip href="http://www.perl.com/pub/a/2003/04/09/synopsis.html">
Lvalue Subroutines
Lvalue subroutines return a "proxy" object that can be assigned to. It's known as a proxy because the object usually represents the purpose or outcome of the subroutine call.
Subroutines are specified as being lvalue using the is rw trait.
An lvalue subroutine may return a variable:
my $lastval;
sub lastval () is rw { return $lastval }
or the result of some nested call to an lvalue subroutine:
sub prevval () is rw { return lastval() }
or a specially tied proxy object, with suitably programmed FETCH and STORE methods:
sub checklastval ($passwd) is rw {
my $proxy is Proxy(
FETCH => sub ($self) {
return lastval();
},
STORE => sub ($self, $val) {
die unless check($passwd);
lastval() = $val;
},
);
return $proxy;
}
</snip>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]