Hi Brian, thanks for your comments, I'll be working on this, expect an implementation sometime in the near future, and structure your code accordingly!
-Sterling On Mon, 2003-01-13 at 17:01, Brian T. Allen wrote: > > From: Andrew Brampton [mailto:[EMAIL PROTECTED]] > > Sent: Monday, January 13, 2003 2:16 PM > > Subject: Re: [PHP-DEV] Feature Request: Auto Include a Function > > > > > > I'm not a PHP Developer but I see a few problems with this. > > I'm not a PHP Developer either, but I use it 12 hours a day in my work. > > > > Since a PHP script is re-evaluated/"compiled" on each > > execution it would > > mean PHP would have to look through all your .php files for > > this file. This > > could be very time consuming, espically since it has to do it every > > execution. > > If a hash file were used it would only have to "search" for the function > once, and even then only in the functions directory (like the include > directory, but specifically for functions). After that the order would > be: > > 1) Execute the function > 2) If the function doesn't exist check the hash file and include it > 3) If it's not in the hash file search for it, include it, then hash it > 4) If it can't be found issue an error message > > If there we're no subdirectories there would be no more overhead than > for a file_exists() call. > > > > Also what happens if you spell a function wrong, OR it finds > > 2 functions > > with the same name in different .php files. > > If you spell a function wrong it isn't going to work either way, and I > think it's a good idea to have your function names be unique within a > give site. > > > > I don't think its got any real advantage over the fact that > > it just lets you > > be lazy. It wouldn't be any quicker in any way. > > One mans laziness is another mans efficiency. If we were after 100% > performance we'd all be programming in machine lanquage. But that fact > is I personally use PHP over other solutions because it's easier to > develop in. > > Given the chance I'll sacrifice a little (in this case very little) > performance to speed up and simplify development. At $50 an hour and 8 > hours per day, ~my~ CPU cycles are worth $8,000 per month. I pay $100 a > month for a server with the majority of CPU cycles going to waste. > Personally I'd rather optimize the $8,000 rather than the $100. > > Not everyone is in my shoes, but adding this won't effect them. The > little bit of overhead to automatically include functions is ONLY > incurred if the function isn't included to begin with. So existing > scripts and programming styles won't be affected at all. > > But I think it would simplify things a LOT on a big site with lots of > functions. > > > If this was a compilable language then sure it would of been > > nice, like C > > does searching through .h files, but since its not I don't > > think its a good > > idea. > > > > Andrew > > Thanks for the reply! > > Brian > > > > ----- Original Message ----- > > From: "Brian T. Allen" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Monday, January 13, 2003 8:21 PM > > Subject: [PHP-DEV] Feature Request: Auto Include a Function > > > > > > > Hi, > > > > > > Please accept my apologies in advance if this is not the > > correct place > > > for this request. > > > > > > This may exist, but I haven't been able to find it, and I > > think it would > > > be REALLY helpful and convenient. > > > > > > The idea is this: > > > > > > When you write a script and call a function: > > > > > > <?php > > > > > > $whatever = previously_uncalled_function("one","two"); > > > > > > ?> > > > > > > PHP could automatically look for a file named > > > "previously_uncalled_function" in your /include/functions/ > > (or whatever) > > > directory. > > > > > > This would eliminate a LOT of include() and require() calls > > (or at least > > > make them automatic) in a script. The function would only > > get read in > > > if it was used. Functions could still be explicitly included or > > > required as they currently are. > > > > > > I *think* the overhead would be about the same as the > > initial include() > > > or require() call would have been. > > > > > > This would be very convenient. When you create a new > > function you drop > > > it in that directory (with a very specific, unique name, of > > course), and > > > it can immediately be called anywhere in the site. And, > > you only incur > > > the disk IO to read it when its used for the first time in a script. > > > > > > The 3 things I want to avoid are: > > > > > > 1) Explicitly including every function, every time it's needed. > > > 2) Disk IO of including a function when it's not needed. > > > 3) Taking the easy route and including a file with a bunch > > of functions > > > when most won't get called. > > > > > > Does this already exist, or is this a good idea (if not, any reasons > > > why)? I personally would love to see it implemented if it isn't > > > already. > > > > > > One possibility for implementation is just prior to the "undeclared > > > function" error message, try to auto include the function prior to > > > generating the error message. > > > > > > Thanks, > > > Brian Allen > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > -- > > > PHP Development Mailing List <http://www.php.net/> > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > -- "Whether you think you can or think you can't -- you are right." - Henry Ford -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php