Re: Code References
| From: | Rasmus Lerdorf | Date: | Mon, 19 May 2003 16:27:34 +0000 |
| Subject: | Re: Code References | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-1724@lists.php.net to get a copy of this message | ||
On 19 May 2003, Sterling Hughes wrote:
> Well, right. As I've mentioned beforehand, speed is really a secondary
> factor, although it does exist, and the concept of code references
> (passing around function pointers as opposed to function names) would
> make php faster anywhere callbacks are used.
>
> But its also a cleanliness and ease-of-use factor. If you look at the
> amount create_function() is used in PHP code, its next to nil. With
> other scripting languages such features are commonly used (and very
> *useful* imho). One could assume this is because PHP users don't need
> it, but I think its more due to the way its kludged in (imho again). I
> think a clear way of having function pointers, and then a nice syntax
> for declaring anonymous subroutines (read: I don't want to stash my code
> inside a variable), would be something really useful.
I really don't like the idea of having a second syntax for what is
essentially exactly the same thing and having that second syntax be
different in a subtle way. The runtime vs. compile time difference is
going cause confusion for people trying to use it. Sort of like the tens
of thousands of questions we had regarding the difference between include
and require before that mess was cleaned up.
So, I am very much against introducing it just because you think it is
prettier (which I don't disagree with). The fact that this feature isn't
used that much today is a damn good thing as far as I am concerned. It
doesn't exactly lend itself to readable code. People who know what they
are doing and understand when to use an anonymous function can handle the
syntax.
-Rasmus