[Kde-perl] Can't debug PQT app ...
Ashley Winters
kde-perl@mail.kde.org
Thu, 19 Dec 2002 00:51:33 -0800 (PST)
--- Germain Garand <germain@ebooksfrance.com> wrote:
> Le Mercredi 18 Décembre 2002 19:22, Ashley Winters a écrit :
> > Did I never mention that assigning to 'this' is deprecated? Umm...
> it
> > should be. Feel free to add a setThis($foo) or whatever, if it'll
> help.
> > There's no need for 'this' to be lvalue. Of course, attributes are
> > something else. :)
> >
>
> Yes, why not... we'll still get BRs for attributes, but that's far
> better.
> Properly informed people could even turaround by assigning
> this->{'foo'}
> instead of foo...
> That one will do great as a new FAQ entry :-D
Heh. If you want to really get rid of lvalue subs, it's perfectly
possible. Here goes:
package Qt::attr::tie;
# example class -- never tried
sub TIESCALAR {
# for something like use Qt::attr qw(name)
# call like tie $foo, 'Qt::attr::tie', 'name'
my $class = shift;
my $attr = shift;
return bless \$attr, $class;
}
sub FETCH {
my $self = shift;
my $this = getThis();
return $this->{$$self};
}
sub STORE {
my $self = shift;
my $val = shift;
my $this = getThis();
$this->{$$self} = $val;
}
Even $this could be supported. Here's a short example from the
tutorials:
# ...
use Qt::attr qw(slider label);
# ...
sub init {
my $lcd = Qt::LCDNumber(2, $this, "lcd");
$slider = Qt::Slider(&Horizontal, $this, "slider");
$slider->setRange(0, 99);
# ...
}
I propose Qt::attr for the "new" version. I'm not sure if Qt::attr
would introduce a tied $this by default, since "this" wouldn't be an
lvalue sub anymore.
Pretty easy to do. Anyone have programming time to burn? :)
Ashley Winters
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com