Lambda the Ultimate

inactiveTopic Automatic Run-time Interface Building
started 9/18/2002; 10:44:24 AM - last post 9/26/2002; 9:18:26 AM
Ehud Lamm - Automatic Run-time Interface Building  blueArrow
9/18/2002; 10:44:24 AM (reads: 2094, responses: 4)
Automatic Run-time Interface Building
(via Daily Python-URL)

...there is often a large barrier to object composition - sometimes a class needs to have the interface of its components. You don't want to extend the functionality of the component, you just want its interface, and you want all calls to that interface to be sent to the component object. In this case, it is so much easier to inherit even though you are not really extending the functionality of the parent class...

Amazingly enough, however, Python allows you to modify classes at run time. This means it is possible to make Python automatically write these wrapper (or proxy) functions for you.

Lateral thinking at its worst?


Posted to OOP by Ehud Lamm on 9/18/02; 10:45:48 AM

Joey deVilla - Re: Automatic Run-time Interface Building  blueArrow
9/19/2002; 10:08:09 AM (reads: 981, responses: 0)
Please elaborate.

Cameron Laird - Re: Automatic Run-time Interface Building  blueArrow
9/23/2002; 5:12:21 PM (reads: 814, responses: 1)
Me, too, Ehud.

I think you're recoiling in horror at the way Python can procedurally muddy class hierarchies. That's my reaction, too. It can lead to terrible code, and I've certainly seen that.

That's not the whole story, though. While I doubt I'll be able to make time this week to explain it, I now believe that it's possible to code type interfaces in the way you describe, but do it in *good* Python style. More, there's even value in doing so.

First, though, can you please make your own position explicit?

Ehud Lamm - Re: Automatic Run-time Interface Building  blueArrow
9/23/2002; 10:37:07 PM (reads: 869, responses: 0)
I am just leaving for a two day holiday. I'll try to say more when I get back.

Ehud Lamm - Re: Automatic Run-time Interface Building  blueArrow
9/26/2002; 9:18:26 AM (reads: 772, responses: 0)
Don't go reading to much into my original comment.

It was just a smart aleck way of pointing out that interfaces should be static, code generation done before run time, and optimization not influence design.

The technique itself was nice enough I linked to it from LtU. I just tried to be funny... Sorry it didn't work.