Re: Gtk3



On 02.04.2011 01:11, Kevin Ryde wrote:
Yes, it does.  It was using AUTOLOAD trickery originally, but that
turned out to be too fragile,

What went wrong?  The only thing I can think of is that on registering a
subclass, any methods which it overrides in a superclass would have to
be created immediately, due to perl's usual preference for an existing
superclass method over an AUTOLOAD.

I originally started out with a single AUTOLOAD in a package which was set to be the parent of any package created for the library in question. (To avoid perl's scorn for inherited AUTOLOAD, I later ended up putting a clone of that global AUTOLOAD into every package.) So, on every method call, you get into this AUTOLOAD with the information that some method was called on some package. To map this to the correct [package, method] tuple, you basically have to reimplement method resolution: walk the parent ancestry in the correct order, also taking interfaces into account. At some point I just thought: perl is better at this than me.*

The problem you mention didn't even occur to me at the time. But it's another argument against AUTOLOAD.

Also, perl doesn't like AUTOLOAD for non-method invocations.

If, after we're done implementing and bug-proofing the current incarnation, we find that the preloading of subs is a performance issue, we can worry about it then. Right now, I think correctness should be the primary goal.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]