> At 09:36 08-09-01, Rasmus Lerdorf wrote:
> > > Using obscure single character operators is simply something that we don't
> > > do in PHP, it's totally inconsistent with the language.
> >
> >You know I hate magic more than most.  I have lobbied against it forever.
>
> Well, 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?

<?= is obviously a concession to ASP users who are used to using <%= just
like _() is a concession to gettext users.  I don't quite see how you can
argue strongly in favour of <?= and at the same time argue so strongly
against _().  Magic is bad and language consistency is good, but allowing
users who are used to certain conventions to continue using them is
sometimes a tradeoff that is worth making.

> Regular expression are butt-ugly by definition.  You can either learn them
> or not learn them.  It's kinda like SQL.  I'm not sure why you're failing
> to see the fundamental difference between a function that is complex and
> perhaps requires prior knowledge, and an entry that obscures the
> *namespace* of PHP.

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.

> When I see ereg_replace(), I can go and learn about regular expressions.
> When I see _(), I don't have the faintest clue what the heck it is.  If I
> even figure out that this is a function (it sure as hell doesn't look like
> one):
> (a) Consult the manual (won't do)
> (b) Consult the function table (won't do)
> If I don't, I can either read the source code or start up a debugger.

Exactly the same goes for <?= unless you happen to stumble across the
one-line footnote on the php.net/echo page.

> 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.

> 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.

-Rasmus


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to