Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95019 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42925 invoked from network); 10 Aug 2016 17:50:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2016 17:50:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.28.122 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.28.122 mx201.easyname.com Received: from [212.232.28.122] ([212.232.28.122:46418] helo=mx203.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/D1-32735-D596BA75 for ; Wed, 10 Aug 2016 13:50:21 -0400 Received: from cable-81-173-132-156.netcologne.de ([81.173.132.156] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bXXdy-0002Ep-Nx; Wed, 10 Aug 2016 17:50:19 +0000 Reply-To: internals@lists.php.net References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> <1d89ec68-de5e-2670-aed1-f12872c073c3@gmail.com> <615f02b9-0621-2e7a-bec9-af4e342529b2@gmail.com> <80776a32-5eda-271f-4270-2843b453a545@fleshgrinder.com> <8ac85eb6-0ecd-7b11-076a-da6cb9fe3184@gmail.com> To: Stanislav Malyshev , internals@lists.php.net, Rowan Collins Message-ID: Date: Wed, 10 Aug 2016 19:50:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <8ac85eb6-0ecd-7b11-076a-da6cb9fe3184@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kbq1aV4bHUvg0PVIXTIT2wD23xDD9557c" Subject: Re: [PHP-DEV] Function auto-loading From: php@fleshgrinder.com (Fleshgrinder) --kbq1aV4bHUvg0PVIXTIT2wD23xDD9557c Content-Type: multipart/mixed; boundary="uCTHSMmSUaDUPLeIKKP9mP16W0lgOLX02" From: Fleshgrinder Reply-To: internals@lists.php.net To: Stanislav Malyshev , internals@lists.php.net, Rowan Collins Message-ID: Subject: Re: [PHP-DEV] Function auto-loading References: <33781781-2a63-78c1-68a1-9e19ad720d8d@gmail.com> <1d89ec68-de5e-2670-aed1-f12872c073c3@gmail.com> <615f02b9-0621-2e7a-bec9-af4e342529b2@gmail.com> <80776a32-5eda-271f-4270-2843b453a545@fleshgrinder.com> <8ac85eb6-0ecd-7b11-076a-da6cb9fe3184@gmail.com> In-Reply-To: <8ac85eb6-0ecd-7b11-076a-da6cb9fe3184@gmail.com> --uCTHSMmSUaDUPLeIKKP9mP16W0lgOLX02 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On 09/08/2016 21:26, Fleshgrinder wrote: >> An alternative approach could be to auto-load only namespaced >> things and leave non-namespaced stuff alone. >=20 > It's not quite as simple as that, as examples have already shown. >=20 > # file a.php namespace Acme\Foo; function a() { return 'Hello > World'; } >=20 > # file b.php namespace Acme\Foo; function b() { $message =3D a(); # > this is a call to Acme\Foo\a return strpos($message, 'Hello'); # this > is a call to \strpos } >=20 >=20 > There's no way of telling that the a() is namespaced and the > strpos() > is global until *after* the autoloader has run. There *might* be a > function Acme\Foo\strpos which is autoloadable. >=20 > Regards, Absolutely true yeah. I guess there's nothing to be done about this without calling the auto-loader all the time plus implementing some cachi= ng. On 8/10/2016 10:58 AM, Stanislav Malyshev wrote: > Hi! >=20 >> Having the use statement trigger the auto-loader would result in a lot= >> of broken code because of optional dependencies (remember the examples= I >> showed you in the annotation thread). >=20 > I think it's not a good idea in general. use statement right now is > basically a syntax sugar - you just change interpretation of names. But= > you don't cause anything to load by this statement. Changing it would > mean people have to change a lot of assumptions about what is loaded > when. E.g., there's a lot of code which use's classes and spaces that > may not even exist - just because they *might* exist in some scenarios,= > and will be used in those scenarios, further down in the code. >=20 > I don't think completely changing the semantics of a very widely used > statement is anything we should be doing. >=20 Ibid. On 8/10/2016 10:58 AM, Stanislav Malyshev wrote: >> This would make it even more painful for users to define anything in t= he >> global namespace; a good thing. >=20 > No it's not. Why should it be a good thing? >=20 Defining anything in the global namespace in userland code is not bad per se. It just creates potential for name collisions in future PHP versions if future PHP versions introduce anything that has the same name. I did not say that we should actively discourage people to define things in the global namespace, on the contrary since having the ability to use this is a core part of PHP, but it would make people more sensible while doing so for their own good. Which is a good thing in my opinion. On 8/10/2016 10:58 AM, Stanislav Malyshev wrote: >> It would however encourage people to prefix their stuff inline with a >> backslash, otherwise you end up with an endless use chain for every >=20 > I'm sorry but this is horrible. PHP code should not look like a fence o= f > backslashes, backslashes do not have any useful function there and in > 99.9999% of cases global functions *are* global functions, and nobody i= s > overriding them. Yes, you can override strlen. No, nobody (within > 0.00001% accuracy) does. >=20 I agree completely and I am afraid of the backslash fence as well, extremely to be honest. On 8/10/2016 10:58 AM, Stanislav Malyshev wrote: >> built-in feature which is not nice. That being said, it's required >> anyways if we are really going to introduce namespaces for everything >> within PHP (e.g. `use function php\random_bytes;`). Something I still >> think is a bad idea at least for procedural first-level functions. >=20 > It's a bad idea for all existing functions and classes. Because it adds= > complications for people without giving them anything in exchange. >=20 Ibid. --=20 Richard "Fleshgrinder" Fussenegger --uCTHSMmSUaDUPLeIKKP9mP16W0lgOLX02-- --kbq1aV4bHUvg0PVIXTIT2wD23xDD9557c Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXq2lUAAoJEOKkKcqFPVVrdeQQAIM9KGQZY/fxQHVqX+g0nhD1 Sb5AmGsVWSo8+kZ2mS/6K5FSWMJl+l/L5cHMD7qeqGCvwXtZ+WmcUaVLfThHbxlQ PTxNBZub2mfh/26/sDRtq8snsKc6Knzice0SFOSJAwGFd9GJrbUYQtwAT20cdwnk 0JLWC+qaWNUY6oBjYPpGGc0BadrLmMjqA1xAHgatBa6SxXvYzl79QBtXUD6Wbay1 WX62cwcyxN3gx6dIpMsNcDjYgljN4g1nTIsFP1AQFjNBF0hBzOvymY8iHk98aFDe iILFU0yu/k3kTacA9cthdjYPgVLvcS0wRmkngQbjyjfCY1l/3tSoUQHS2Lo/B1JF 7XxVHW+hIGnfqMLHr8o6IWaVpEAA5CwVxC3aIDu6IEAu/ezThQKVThxy09RtsR33 lpDh/q304u1VG21NFE4d73vYKls1EuD4o4w5b/bbxzRPrhr212Xnap7nGaRHfSGa XgnAzrEawlZ+amHAsT2dZD5IMf7NN1UkDnqRiL6dKjVU3RJ4DSjQJmZeooHndwuB ZpPyOSRLpD/mpCRhK/Ky5q0rcXf5mw8lM7VUwD8CurhGpG3U06wHCAn0pfcsjtRv 8ZwCY5ca6lPqpR4YGe6N/GwkIInBb44i2XL2XZ2bxKX/c9Y+VRi2bFuuzxtICM/p F6v29wNq7aUj1MtkFqSp =Tozj -----END PGP SIGNATURE----- --kbq1aV4bHUvg0PVIXTIT2wD23xDD9557c--