Stanislav Malyshev wrote:

> Well, I can tell you what's bad for you but I can't stop you from doing
> that :) use * is bad for you, but if you insist on simulating it - well,
> ok, it's your code.

I suspect even ZF will run into some kind of import * functionality
being needed.  Do you really want to tell a user they have to write 18
use statements before using say the DB component?  Or for PEAR2? when a
pear_import_package($packagename, $importbase); would get it all done
for them? sorry but users do NOT like to type.

>> Here's a quick use case for you -> you have a group of "helper
>> functions" for a PHP based template system.  You want to have those
>> functions in "global scope" for the template (and yes, you might want to
>> override strlen) and no, you don't want your templates to be using
>> static calls into namespaced functions.
> 
> I don't see in this case why:
> a) tmpl::display("mywidget") or html::b("foo") is unusable as helper
> functions? For me it looks even better - you can actually have
> meaningful names without them looking awkward!

As you said before - how is it any different from just being able to
call escape("foo") or display("foo"); It's a matter of taste.  To me
that is not anymore of a meaningful name - just a different syntax and
not one your average wordpress user would know how to handle.

> b) overriding strlen makes any sense even for helpers? Just to confuse
> the hell out of readers?

No - imagine your app is all unicode and you want strlen to actually use
an mbstring or iconv implementation - you could wrap that transparently
for your template authors.

> c) you don't want templates to make static calls?

Sometimes security is important in templates, depending on who is
creating them and how you allow users to edit them.  Not all
applications have the same requirements.

> BTW, see how it's solved in Zend Framework - works just fine. Extremely
> pluggable and doesn't require you to pollute global space.

First of all, with namespaces and the ability to alias functions you
wouldn't pollute the global space, you'd only push your helpers into the
global space where the templates would use it.  Secondly, I don't
approve of the one class for every helper - feels bloated.  As I said
before, not all applications have the same requirements.

Thanks,
Elizabeth

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to