Re: [PHP-DEV] Not autoloading functions

2017-01-30 Thread Tony Marston
"Rowan Collins" wrote in message news:ae15f883-bdba-89ea-9e6a-6e3b09745...@gmail.com... On 29/01/2017 15:37, Wes wrote: Curious that those who are posting here put all functions in the same file. So, why don't you just require_once('Namespace/functions.php') ? By that argument, why not

Re: [PHP-DEV] Not autoloading functions

2017-01-30 Thread Tony Marston
"Wes" wrote in message news:CAOv67gtxm0muzuKrQyizgkM9Pf0hn7E-iTBXpq1VV9D8aUWM=w...@mail.gmail.com... Curious that those who are posting here put all functions in the same file. So, why don't you just require_once('Namespace/functions.php') ? I do, but without using namespaces. I actually

Re: [PHP-DEV] Not autoloading functions

2017-01-29 Thread Rowan Collins
On 29/01/2017 17:56, Wes wrote: Hi Rowan, I probably wasn't clear enough. How is having to write use namespace Foo\Bar\Baz; better than require_once("../Foo/Bar/Baz/functions.php"); OK, your last question just mentioned putting multiple functions in one file, not that you were addressing that

Re: [PHP-DEV] Not autoloading functions

2017-01-29 Thread Wes
Hi Rowan, I probably wasn't clear enough. How is having to write use namespace Foo\Bar\Baz; better than require_once("../Foo/Bar/Baz/functions.php");

Re: [PHP-DEV] Not autoloading functions

2017-01-29 Thread Rowan Collins
On 29/01/2017 15:37, Wes wrote: Curious that those who are posting here put all functions in the same file. So, why don't you just require_once('Namespace/functions.php') ? By that argument, why not just require_once('Namespace/ClassName.php)? It turns out that many people find autoloading a

Re: [PHP-DEV] Not autoloading functions

2017-01-29 Thread Wes
Curious that those who are posting here put all functions in the same file. So, why don't you just require_once('Namespace/functions.php') ?

Re: [PHP-DEV] Not autoloading functions

2017-01-29 Thread Tony Marston
"Niklas Keller" wrote in message news:canuqdci945m2tddzty_tuuhdqn1xj9wjgsl_eqbyqr5f7_x...@mail.gmail.com... I'm sorry, it's unacceptable for who? Only for not defined function it would be called. If I call the same function a thousand times, the autoload will be attempted just the first

Re: [PHP-DEV] Not autoloading functions

2017-01-28 Thread Niklas Keller
2017-01-28 21:37 GMT+01:00 Wes : > I suppose that is because they use just few functions. I don't think you > would want to have 20-30 functions in the same file :P > I wouldn't call these just a few functions: - https://github.com/nikic/iter/blob/master/src/iter.php -

Re: [PHP-DEV] Not autoloading functions

2017-01-28 Thread Wes
I suppose that is because they use just few functions. I don't think you would want to have 20-30 functions in the same file :P

Re: [PHP-DEV] Not autoloading functions

2017-01-28 Thread Niklas Keller
> > I'm sorry, it's unacceptable for who? Only for not defined function it > would be called. If I call the same function a thousand times, the autoload > will be attempted just the first time, and if it doesn't work then the > script would die, exactly like classes. Any project I know that uses >

Re: [PHP-DEV] Not autoloading functions

2017-01-28 Thread Wes
> > old applications could maintain compatibility only > > by adding a simple autoloader that would alias the global > function/constant > > into the calling namespace > > So as a side-effect of calling any function, my namespace would get > polluted with all sorts of random names? That sounds

Re: [PHP-DEV] Not autoloading functions

2017-01-28 Thread Rasmus Schultz
> old applications could maintain compatibility only > by adding a simple autoloader that would alias the global function/constant > into the calling namespace So as a side-effect of calling any function, my namespace would get polluted with all sorts of random names? That sounds like a messy

Re: [PHP-DEV] Not autoloading functions

2017-01-27 Thread Wes
Importing functions from a static class would equally require to have all functions in the same file. I was proposing an alternative to that, not "symbol to file" autoloading. Though, I know that problem well, sadly. I've suggested PHP should just deprecate the fallback to root namespace, and

Re: [PHP-DEV] Not autoloading functions

2017-01-27 Thread Nikita Nefedov
On Fri, 20 Jan 2017 10:04:44 +0300, Rasmus Schultz wrote: Just a quick thought. Since the autoloading functions proposal is stalled, how about allowing for import of static functions instead? use function Foo::bar; bar(); // calls Foo::bar() There are two

Re: [PHP-DEV] Not autoloading functions

2017-01-27 Thread Rowan Collins
On 27 January 2017 09:23:38 GMT+00:00, Wes wrote: >An alternative (which I haven't properly developed yet). Thoughts? >\A\B\someFunction(); >// prints: >// LOADING A\n >// LOADING AB\n As I understand it, PHP namespaces aren't really hierarchies, they just have a

Re: [PHP-DEV] Not autoloading functions

2017-01-27 Thread Wes
An alternative (which I haven't properly developed yet). Thoughts? ``` define_autoload(AUTOLOAD_NS, function($ns){ if($ns === '\A\B\C'){ echo "LOADING ABC\n"; require(__DIR__ . $ns . '\functions_and_constants.php'); } }); define_autoload(AUTOLOAD_NS, function($ns){

Re: [PHP-DEV] Not autoloading functions

2017-01-26 Thread Nikita Popov
On Thu, Jan 26, 2017 at 10:46 AM, Niklas Keller wrote: > > > > Since the autoloading functions proposal is stalled, how about allowing > for > > import of static functions instead? > > > > use function Foo::bar; > > > > bar(); // calls Foo::bar() > > > > There are two

Re: [PHP-DEV] Not autoloading functions

2017-01-26 Thread Niklas Keller
> > Since the autoloading functions proposal is stalled, how about allowing for > import of static functions instead? > > use function Foo::bar; > > bar(); // calls Foo::bar() > > There are two benefits to this approach: > > 1. There is immediate support for autoloading without any need

Re: [PHP-DEV] Not autoloading functions

2017-01-21 Thread Marcio Almada
Hi, Rasmus! 2017-01-21 4:14 GMT-04:00 Rasmus Schultz : > > How hard is it to write Foo::bar? You never have to go more > than one level. I don't see a point in mixing internal function > namespace with class methods for the sake of saving typing couple of > characters. > >

Re: [PHP-DEV] Not autoloading functions

2017-01-21 Thread Rasmus Schultz
> How hard is it to write Foo::bar? You never have to go more than one level. I don't see a point in mixing internal function namespace with class methods for the sake of saving typing couple of characters. I'm not suggesting we mix namespaces - this of course would be file-local, same as

Re: [PHP-DEV] Not autoloading functions

2017-01-20 Thread Fleshgrinder
On 1/20/2017 7:58 PM, Nikita Popov wrote: > On Fri, Jan 20, 2017 at 7:55 PM, Stanislav Malyshev > wrote: > >> Hi! >> >>> Since the autoloading functions proposal is stalled, how about allowing >> for >>> import of static functions instead? >>> >>> use function Foo::bar;

Re: [PHP-DEV] Not autoloading functions

2017-01-20 Thread Nikita Popov
On Fri, Jan 20, 2017 at 7:55 PM, Stanislav Malyshev wrote: > Hi! > > > Since the autoloading functions proposal is stalled, how about allowing > for > > import of static functions instead? > > > > use function Foo::bar; > > > > bar(); // calls Foo::bar() > > I'm not

Re: [PHP-DEV] Not autoloading functions

2017-01-20 Thread Stanislav Malyshev
Hi! > Since the autoloading functions proposal is stalled, how about allowing for > import of static functions instead? > > use function Foo::bar; > > bar(); // calls Foo::bar() I'm not sure why it is good. This would certainly be confusing, if you call strlen and turns out it's

Re: [PHP-DEV] Not autoloading functions

2017-01-20 Thread Paul Jones
> On Jan 20, 2017, at 01:04, Rasmus Schultz wrote: > > Just a quick thought. > > Since the autoloading functions proposal is stalled, how about allowing for > import of static functions instead? > >use function Foo::bar; > >bar(); // calls Foo::bar() > ... > at

Re: [PHP-DEV] Not autoloading functions

2017-01-20 Thread Fleshgrinder
On 1/20/2017 8:04 AM, Rasmus Schultz wrote: > Just a quick thought. > > Since the autoloading functions proposal is stalled, how about allowing for > import of static functions instead? > > use function Foo::bar; > > bar(); // calls Foo::bar() > > There are two benefits to this

[PHP-DEV] Not autoloading functions

2017-01-19 Thread Rasmus Schultz
Just a quick thought. Since the autoloading functions proposal is stalled, how about allowing for import of static functions instead? use function Foo::bar; bar(); // calls Foo::bar() There are two benefits to this approach: 1. There is immediate support for autoloading without any