Re: Function autoloading

From: Date: Sat, 31 Aug 2013 18:03:01 +0000
Subject: Re: Function autoloading
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
2013/8/31 Vartolomei Nicolae <[email protected]>

> So you say you will create a file for every function you want to support
> autoloading?
>

I already _have_ create files for functions of a namespace... Closed
source.


> As I already asked, tell us about realworld use case, for example where
> this could improve say big projects like Symfony or ZF.
>

Not everything can be found in the 5 most popular frameworks.


> There is no logic to add this functionality just because we can.
>

The lack of logic is: Why is it actually missing?

- Classes: Triggers an autoloader
- Functions: Needs manual handling
- Constants: Needs manual handling

That is at first inconsistent. The need of "require_once"s is inefficient
and error prone.

Regards,
Sebastian


>
>
>
> kindly,
> nvartolomei
>
>
> On Friday, August 30, 2013 at 8:38 PM, Nikita Popov wrote:
>
> > On Fri, Aug 30, 2013 at 7:10 PM, Stas Malyshev <[email protected](mailto:
> [email protected])>wrote:
> >
> > > Hi!
> > >
> > > > Well, static methods aren't the same as functions.
> > >
> > > The big difference being?
> >
> > This seems to be the core of your argumentation in this thread: "Why
> don't
> > you just use Foo::bar() instead of foo\bar()?"
> >
> > In which case, I wonder why we have functions at all. We could just use
> > static methods instead after all. Maybe we should deprecate function
> > support?
> >
> > On a more serious note: If you want an actual example of how functions
> can
> > be easier to use than static methods, consider the "use function" RFC.
> Now
> > that it's in, it is possible to directly import a function foo\bar() and
> > use it with just bar(). Static methods allow no such thing. You always
> need
> > to write the class name.
> >
> > The reason why people currently resort to using static methods instead of
> > functions is the fact that there is no autoloading for functions. With
> > autoloading, functions become a lot easier to use.
> >
> > Nikita
>
>
>


-- 
github.com/KingCrunch


Thread (72 messages)

« previous php.internals (#68782) next »