Re: Woah
| From: | Zeev Suraski | Date: | Sat, 08 Sep 2001 21:58:49 +0000 |
| Subject: | Re: Woah | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-65501@lists.php.net to get a copy of this message | ||
At 19:29 08-09-01, Rasmus Lerdorf wrote:
At 09:36 08-09-01, Rasmus Lerdorf wrote:I don't consider <?= magic anymore than <?. It should be documented in the list of PHP's special tags. You could argue the same about <? itself, they're equally fundamental. _() is magic, magic quotes is magic. <?= is some trick, at best :)we don'tUsing obscure single character operators is simply something thatWell, you did in certain occasions, but you encouraged certain degrees of magic in the past. As did you. You don't call <?= magic? You lobbied hard to make that active by default. I wouldn't call <?="Whoa"?> pure, would you? If you don't know what it does, where do you start looking?do in PHP, it's totally inconsistent with the language.You know I hate magic more than most. I have lobbied against it forever.
There is a heck of a lot more to gettext than just knowing the gettext() function. Anybody who inherits code which uses gettext is going to have to read up on textdomain, .po files and the other related crud and understand the conventions. One of these conventions, like it or not, is _(). None of this stuff is covered in the PHP documentation. Just like anybody who inherits PHP code with regular expressions or complex SQL are going to have to read up on the conventions of those technologies which also aren't covered in the PHP docs.You still don't see the point. People don't have the faintest clue that _() is even related to gettext! It doesn't look like a function but as some form of an internal operator.
Exactly the same goes for <?= unless you happen to stumble across the one-line footnote on the php.net/echo page.So that's a documentation bug. It clearly belongs in the documentation about PHP's various special tags, just next to <?php, <?, <%, <%= <script language="php">, etc. There's a logical place to look for that entry.
Cris showed a trivial way of doing that, if users actually want to do it. function _($str) { return gettext($str); }. You don't need any new mechanisms or magic to do this. We both know that this is going to affect performance. Just for kicks I tested this on one of my gettext pages. I picked a relatively simple one that didn't have any SQL or LDAP queries in it. With the _() calls it managed 110 requests/second. With: function g($str) { return gettext($str); } it got 81 requests/second. To me that is not a trivial workaround. And like I mentioned before, if we had some way of installing this function in the namespace dynamically, I would be all for it.We could have a way of aliasing functions.
At least give the user the option to decide whether he wants to pollute his namespace. At least give the code readers a chance to figure out what's going on by grepping the PHP source code. Sending them to the C source code or to debuggers is the old style thinking of PHP. Most new comers to PHP today have no C knowledge. And most have ASP knowledge? And where is my option to not pollute PHP with <?= ? Even with asp_tags set to off <?= is still active.You're right that <?= is not self explanatory. FWIW, it still falls in a very clear category of language-level features, right next to <? and <?php, which you have to learn anyway (and again, if it's missing, so that's a documentation bug that can be fixed). This is not something you could say about _(). Zeev