[Kde-perl] Signals & Slots

Ashley Winters jahqueel at yahoo.com
Wed Jun 4 01:27:13 CEST 2003


Umm... Request For Comments? I've been thinking about how to come up
with a real syntax (as opposed to the current kludge) for
signals/slots. Here goes:

sub foo : signal( foo(int) );   # no body!

sub hitButton : slot( hitButton(QWidget*, const QString &) ) {
    my $w = shift;
    my $str = shift;
    # ...
}

And, when PerlKDE gets released:

sub doSomething : dcop( doSomething(const QString &) ) {
    my $thing = shift;
    # ...
}

Everyone agree that Perl sub attributes are the way to go? Yes? Anyone
want to submit a patch that makes this happen? :)

It's a PerlQt/KDE attribute if /^ (signal|slot|dcop) \( .* \) $/x

Beware of trivial argument parsing... split "," will not do what you
want (think: "slot( foo(QClass<int,int>, QString&) )"). Consider using
(??{}) recursiveness.

To be honest, I can't think of a simple way to go from CODE->GLOB->name
from within Perl without using some B:: goodies, so some XS may be
required to tuit the name of the sub the attribute is being applied to.
Then again, perhaps future versions of PerlQt will allow slots to be
directed to anonymous subs. :)

I'm also thinking about plugging PerlQt into POE. Seems interesting.
Later, though.

Ashley Winters

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com


More information about the Kde-perl mailing list