Re: Re: Function Cache

From: Date: Sun, 10 Dec 2000 17:43:27 +0000
Subject: Re: Re: Function Cache
References: 1 2 3 4 5  Groups: php.dev php.pear 
Request: Send a blank email to php-dev+get-40752@lists.php.net to get a copy of this message
> Sterling Hughes wrote: > > Basically what this functionality would allow is that you > > define a function that then catches as missed function calls. > > The autoload variable would also contain the name of the > > missing function, ie: > > Does this actually define code, i.e. use up memory? This would > do, but my proposal was more along the lines to intercept the > error message ("undefined or unsupported function") and have a > user function provide a single instance of code for all possible > calls. Slower, I think, but more conservative on memory - a > design decision, either implementation would be valid. > Actually, the proposed implementation of autoload won't slow down the code at all, that is unless you call an undefined function, then it would do a lookup on the function table to see if the autoload function was available and populate the global symbol table with the $AUTOLOAD variable if there is an autoload function (and replace the invalid function name with the AUTOLOAD function). > > $wrap = new wrapper; > > $wrap->hello("woohooo!"); > > > > would call the AUTOLOAD function with one argument (woohooo!) > > and the global variable $AUTOLOAD would contain "hello". > > Ugly. The global $AUTOLOAD should be an arg to AUTOLOAD() > instead. > I don't think its that ugly, and its faster the way it is... I originally was populating the functions symbol table with an $AUTOLOAD variable, however, that requires an extra if (...) statement for every function call, instead if you have it as a global variable then AUTOLOAD will not have any effect speed wise, unless you use it (and then only a small effect). -Sterling

« previous php.dev (#40752) next »