|
Posted by Jochem Maas on 06/02/05 14:45
Richard Lynch wrote:
> On Wed, June 1, 2005 3:53 am, Marcus Bointon said:
>
>>On 1 Jun 2005, at 11:38, Jochem Maas wrote:
>>
>>
>>>all true, now imagine that you install a couple of 3rdparty php5
>>>'packages'
>>>and they all define __autoload() - ain't gonna work! which is why
>>>there has been
>>>discussion on internals regarding the possibility of use a handler-
>>>function stack
>>>for autoloading (in the same way that you can register a stack of
>>>input/output
>>>filter-function)... something to keep an eye on in case things
>>>change :-)
>>
>>I've run into this one. One way that would work for me (and initially
>>it's how I assumed it worked) is for __autoload to be a standard
>>class method like __construct, so that a class would attempt to run
>>its own autoloader before breaking out to the global function namespace.
>
>
> Maybe I'm being dumb, but how can an object's __autoload function get
> called when the object class definition hasn't been loaded, and that's why
> you're calling __autoload in the first place...
>
> That seems like classic chicken/egg situation to me...
>
that was my first reaction, but then I thought what if the __autoload()
function was called when 'any' class needed to be included while running
code inside said class... that _might_ actually be useful
at any rate the __autoload() issue is still very much undecided :-)
> It's also incredibly likely that __autoload's being "stacked" won't work
> out too well.
>
> Consider this:
>
> foo software defines an __autoload
> Some foo_* classes get defined, autoloaded, everybody's happy.
> bar software defines an __autoload
> Some bar_* classes get defined, autoloaded, everybody's happy.
> Now some foo_* classes try to get instantiated, for whateve reason.
> bar's __autoload function is gonna kick, and that ain't good for foo_*
>
> Seems to me you'd need an array of regular expressions and the function to
> call:
>
> array('foo_*'=>'foo__autoload', 'bar_*'=>'bar__autoload')
>
> if you wanted to allow multiple __autoload functions to exist...
>
> I'm sure there are other ideas/solutions floating around, but that's A
> possibility.
>
> For performance, maybe just use stristr and 'foo_' instead of RegEx and
> 'foo_*' [shrug]
>
Navigation:
[Reply to this message]
|