RE: [SMARTY] new plugin: mailto
| From: | Alan McFarlane | Date: | Wed, 22 May 2002 20:36:07 +0000 |
| Subject: | RE: [SMARTY] new plugin: mailto | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4366@lists.php.net to get a copy of this message | ||
The reason for using my method:
for ($i = 0, $j = count($mail_params); $i < $j; $i++)
{
//...
}
is quite simple. I use a similar construct in lots of languages, and
since I switch between languages frequently, it means I only have to
remember one very simple optimization.
It also allows me to perform some basic translation of languages without
having to implement other constructs. 'foreach' for example in not
supported in many of the languages I use, however 'for' is supported
in (almost) all of them.
Standardization across languages, improves productivity by reducing
the learning curve and making the transition from one to another
easier IMHO.
--
Alan
-----Original Message-----
From: Simon Willison [mailto:simon@incutio.com]
Sent: 22 May 2002 17:42
To: Ivo Jansch; Alan McFarlane
Cc: Smarty General
Subject: Re: [SMARTY] new plugin: mailto
At 16:44 22/05/02 +0200, Ivo Jansch wrote:
>>for ($i = 0, $j = count($mail_params); $i < $j; $i++)
>>{
>> //...
>>}
>
>Wouldn't this be even faster?
>
>foreach ($mail_params as $param)
>{
>}
>
>Maybe it's slower, maybe php is optimised to do this very fast..
>In any case it looks cleaner.
I use foreach extensively in my own code because it is convenient, but it
is by no means efficient. As I understand it, it makes a copy of each item
of the array in turn. Also (unrelated to Smarty but important to know) if
you are working with objects it makes a COPY of each object and operates on
that rather than operating on a reference to the original object - this is
bad for performance and can lead to worrying side effects if you are
expecting a method to be called on a specific object rather than a copy of
it.
HTH,
Simon
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php