| Newsgroups |
gmane.comp.cms.xaraya.devel |
| Organization |
Xaraya |
| Message-ID |
<[email protected]> |
Marcel van der Boom wrote:
> On 23 jul 2009, at 19:46, [email protected] wrote:
>
>> ... but the point is
>> that using the autoload mechanism automatically ensures that only what's
>> actually needed is loaded. Like the consistent use of interfaces, saves
>> us from ourselves...
>
> One thing to keep in mind perhaps is performance. The rationale for the
> import method back then was speed, nothing more, nothing less. There
> should be some notes of my benchmarking on mailing lists or in
> repository. At the time autoload was so buggy it was not even worth
> considering, this may have improved (it should).
>
> The penalty for autoloading (apart from some ad-hoc naming convention)
> is that the system has /some/ information on where to look for certain
> classes, to be used at the time a class is not found as opposed to the
> /exact/ information sys::import provides.
> I have no idea what the search time penalty for that is, but it may be
> worth benchmarking that, at least for the common inclusion routes.
In this scenario the autoload function has the exact information and can
go load the correct file directly. For the performance reason you
mention I don't see this exercise as going beyond cases where the exact
information is known, which for now are the classes in the modules'
class directories and (maybe) the core classes under lib/xaraya. I don't
think it even makes sense to use the mechanism for loading dataproperty
classes, or for that matter the interface classes we use in some places.
In the two cases above, however, the performance hit should be: failing
to find the class among those loaded, and then calling the autoload
function, which itself is already loaded. One would expect that to be
quite small.
Cherry picking the cases in which to use the mechanism introduces a bit
of confusion perhaps ("when do I need to use sys::import?"), but on the
other hand most classes live in the background, and the occasional
module developer will probably not often have to worry about this issue.
For module developers, I think the mechanism could be useful because it
gives some guidance on where to place their classes and how to name
them, apart from the obvious advantage of allowing them to skip the
sys::import lines in the code.
Marc