[pmwiki-users] Request input on soon-coming FAST Data release

Joachim Durchholz jo at durchholz.org
Wed Oct 4 16:47:10 CDT 2006


Crisses schrieb:
> You may not know every built-in function in PHP, or that  
> calling variables into functions by reference is faster and saves  
> memory. (PM reminded me of that last night -- oops)

Ordinarily that's true, but IIRC not in PHP. PHP uses copy-on-write 
logic for strings and arrays, and references are somehow cludged around 
that - at least that's what I remembered reading in the PHP docs.

 > Caveman wrote:
>> One solution is to leave as is, and suggest users simply delete out
>> any functions they don't want (my original thought).  Second solution
>> is to put the less used functions at the end, commented out, and have
>> authors cut and paste them into the data engine (at a point indicated)
>> to add those specific functionalities.

This sounds like premature optimization to me.
PHP parsing times aren't very high - not in comparison to running PHP 
code anyway. I wouldn't worry too much about that before hitting the 
1,000 lines of code barrier.

Inefficiencies in the code are a much more interesting field for 
optimization.

 >> A third option might be to
>> break it up into several recipes, and dynamically include them as they
>> are needed into the main recipe (is that possible?).

Yes.

You can even put most kinds of declaration (functions, global/static, 
etc.) inside an "if" statement; the declaration will take effect only if 
the condition holds.
However, I say that only to show the flexibility of PHP. In practice, 
it's usually not a good idea, at least for functions, because that 
breaks some caching mechanisms that may be installed on the server for PHP.
You can even include a file from within a function. That's rarely done 
however, and probably not well-supported (i.e. likely inefficient); 
besides, it has ramifications for variable scope.

 >>  Something like:
>>
>> if (field == "email") {
>>      include data-email.php;

Don't forget the quotes:
         include 'data-email.php';

>>      email($value);
>>      }

On naming: DataPage might be good enough. Abbreviate to DP_whatever.
Zip and Flex and whatever are all nice and dandy, but they don't *mean* 
a thing, resp. don't properly describe what the recipe is doing.

Regards,
Jo




More information about the pmwiki-users mailing list