[Kde-bindings] QtRuby virtual method callbacks

Ashley Winters jahqueel at yahoo.com
Tue Jul 22 02:18:16 UTC 2003


--- Richard Dale <Richard_Dale at tipitina.demon.co.uk> wrote:

> Thanks - it's great how well your 'Smoke Marshalling Framework' could
> be 
> adapted to ruby, when you probably didn't have ruby in mind when you
> were 
> designing it. I don't think it would be too difficult to have the
> ruby 
> runtime load a perl KPart, and the ruby plugin would be informed of
> which 
> virtual methods had been overriden in perl. When the KPart was
> running and 
> there was a virtual method callback the ruby plugin would first check
> that 
> the method hadn't been overriden in ruby, and if not then it would
> call the 
> perl version.

..............

Dynamic languages lend themselves to be good application servers.
Consider:

#!perl
$ruby = Somehow::getObjectFromRuby('objectID');
$ruby->function(1);

Now, Perl somehow passes the following information to ruby:

objectID, function, 1

And ruby evals the goodies:

objectID.function(1)

Same for the reverse.

foo = getObjectFromPerl("perlObject");
cursor = foo.getCursor()
print cursor.width()

both foo and cursor (a QCursor, presumably?) would be object in Perl
with remote handles in Ruby. I had considered doing that in a Perl-only
way to let Perl programs automate each other, but there's no reason it
can't work between any dynamic languages.

In fact, if you're tricky, you could completely hide the implementation
from the code. Ruby could think that it's the program in which
something is being implemented, but Perl is actually doing callbacks to
do it.

You could implement an entire widget in Ruby, but have that widget
actually be created in a Perl script... whenever a virtual function is
called, it's routed into Ruby. If Perl overrode a Ruby widget, Perl
would automatically call Perl's overridden one.... I like my train of
thought here. Would even work for other languages. OK, enough of that.

Ashley Winters


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


More information about the Kde-bindings mailing list