Re: Re: Function autoloading

From: Date: Mon, 02 Sep 2013 20:02:55 +0000
Subject: Re: Re: Function autoloading
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi!

> So the only case this effects is that you can't autoload a function from
> the same namespace that you're currently in without explicitly using
> that function. 
> 
> That's not such a huge issue.

I think it is such a huge issue, because this means this functionality
can not be used for reliably loading namespaced functions without prior
declaration, and this is pretty much the use case we've been preached
about all along. So if it doesn't work in this case without prior
declarations just for it, than how it's better than require?

> But "fixing" that would be such a massive BC break...

There's nothing to "fix", it was a conscious decision about how
namespaces must work. Alternative is doing \strlen each time you need
string length, which would be just silly.

> You would only need to explicitly use function those in your current
> namespace. Any outside (relative or absolute calls) would still work fine.

It's not "only" - functions in current namespace are exactly those I'm
likely to use.

> And after all, this is the exact reason we implemented use function.
> Because namespaces WERE useless for functions until last week. Now we
> have the power to be explicit with our calls. 

I don't think RFC proposed well before this issue was raised was
actually meant only to fix broken function autoloading proposal. I
sincerely hope it has more uses than that, otherwise it's a pretty big
mistake.

> That's how functions (and namespaces) have always worked. Give it a
> try: http://3v4l.org/S6FN8 Keep in mind, functions have
> been treated as

No it's not how it worked - function resolution rules were always "try
namespace, then global", unless alias is explicitly specified by use
(aliased name is treated as fully qualified, because this is what the
function of aliasing is). Just try to remove "use" statement and see.

> The big difference is that last time there was no mechanism to be
> explicit with what you wanted your code to do without fully qualifying
> every call. Today we have use function.

Which is the same specification, just at the beginning of the file. I'd
rather do one require then ten use functions. My opinion is producing
autoloader that is inconsistent with how language itself treats import
would only produce more WTFs and more people thinking nothing in PHP
makes sense and nobody cares about internal consistency of the language.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227


Thread (72 messages)

« previous php.internals (#68857) next »