Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88259 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44360 invoked from network); 16 Sep 2015 20:04:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2015 20:04:08 -0000 Authentication-Results: pb1.pair.com header.from=rewilliams@thesba.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rewilliams@thesba.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thesba.com designates 208.106.205.210 as permitted sender) X-PHP-List-Original-Sender: rewilliams@thesba.com X-Host-Fingerprint: 208.106.205.210 ntsexchedgea1.newtekemail.com Received: from [208.106.205.210] ([208.106.205.210:56314] helo=NTSEXCHEDGEA1.nts.phx1) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/60-41443-43BC9F55 for ; Wed, 16 Sep 2015 16:04:05 -0400 Received: from NTSMAILBOX1.NTS.PHX1 (208.106.205.232) by NTSEXCHEDGEA1.nts.phx1 (208.106.205.210) with Microsoft SMTP Server (TLS) id 15.0.847.32; Wed, 16 Sep 2015 13:03:50 -0700 Received: from NTSMAILBOX1.NTS.PHX1 (2002:d06a:cde8::d06a:cde8) by NTSMAILBOX1.NTS.PHX1 (2002:d06a:cde8::d06a:cde8) with Microsoft SMTP Server (TLS) id 15.0.847.32; Wed, 16 Sep 2015 13:03:42 -0700 Received: from NTSMAILBOX1.NTS.PHX1 ([fe80::51f0:160d:841f:d989]) by NTSMAILBOX1.NTS.PHX1 ([fe80::51f0:160d:841f:d989%13]) with mapi id 15.00.0847.030; Wed, 16 Sep 2015 13:03:42 -0700 To: Stanislav Malyshev CC: internals Thread-Topic: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? Thread-Index: AQHQ36zP6Wb5e1HnokKnJlazAkejtZ4eJ62AgABxe4CAAAPLgIAAJlKAgAAUa4CAACGZAIAAGymAgAjS3QCAAJOjgIAA+D+AgAA5fACAB+afgIAB6WsAgAFo8ICAACyWAIAHac+AgAAGeYCAAD+qgIAAAnkAgABF9ACAAAG1gIAAJ92AgAAFuoCAADs0MIACm9OAgAAanQA= Date: Wed, 16 Sep 2015 20:03:42 +0000 Message-ID: <440C64A2-4B4F-4AEF-ACE3-F3A6637EBAB6@thesba.com> References: <55DDD60F.5090509@gmail.com> <8C74463E-DBA2-4015-8159-0B44D973387F@craigfrancis.co.uk> <55DE0907.6040904@gmail.com> <1F615BCD-1B9B-4C51-A210-869F1AA1F6E3@craigfrancis.co.uk> <55E5EBBF.6020803@gmail.com> <0BA3A129-D356-4781-B6DE-E2B5A7924AE2@craigfrancis.co.uk> <55E6EC36.6090301@gmail.com> <9AF329EC-99A5-412D-A52B-432627A5520F@gmail.com> <6F4D91EE-B56E-4B83-B1AF-598C3F6897FC@craigfrancis.co.uk> <55F07BA4.2000204@gmail.com> <55F6B911.9080400@gmail.com> <96BE7F01-D04B-483B-B1A3-B45CED6DFCDC@craigfrancis.co.uk> <55F6F08C.1020506@gmail.com> <0BEF6D82-CB5F-49F6-A3A4-3267924A0CDA@thesba.com> <55F72CA9.2060301@gmail.com> <09369945-76FE-4E08-9C2C-15FB0577AD27@thesba.com> <55F752E7.9070801@gmail.com> <55F9B4C7.3050700@gmail.com> In-Reply-To: <55F9B4C7.3050700@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [172.16.153.36] Content-Type: multipart/signed; boundary="Apple-Mail=_F2CA37B9-E7ED-4F0C-8ACC-FA2016460A94"; protocol="application/pgp-signature"; micalg=pgp-sha512 MIME-Version: 1.0 Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rewilliams@thesba.com (Robert Williams) --Apple-Mail=_F2CA37B9-E7ED-4F0C-8ACC-FA2016460A94 Content-Type: multipart/alternative; boundary="Apple-Mail=_01B0878C-B4CC-4A07-9E69-4A9CBD151659" --Apple-Mail=_01B0878C-B4CC-4A07-9E69-4A9CBD151659 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 On Sep 16, 2015, at 11:28, Stanislav Malyshev = wrote: >=20 >> 1 PHP defines null to include variables that have "not been set" 2 >=20 > No, not really, PHP does not define that. It does according to the docs: "A variable is considered to be null if [=85] it has not been set to any = value yet." http://php.net/manual/en/language.types.null.php = I think that=92s more sloppy documentation (declared versus defined) as = opposed to literal truth, but=85. >> PHP also defines null to include variables that have been unset() >=20 > No, PHP does not define anything like that. In fact, unset() means the > variable is destroyed and does not exist (of course, excepting = refcount > etc. issues). Null does not feature in this story at all. I=92ll refer again to the above documentation: "A variable is considered to be null if [=85] it has been unset().=94 This one can=92t be chalked up to sloppy writing. Here, something is = just plain wrong. All of the above does touch on the gap, though. Ignoring the docs and = looking at actual behavior of PHP, it=92s clear that an undefined = variable behaves differently from one assigned null. One can easily tell = if a variable is null, but one can=92t easily tell if a variable is just = not defined. That strikes me as an oversight especially given the fact = that one can use unset() to make a variable once again undefined. Put = another way, we can create and destroy, but we can=92t identify = existence. It=92s a small gap in language design. There are workarounds, = but they=92re workarounds. > That's not a correct description. Correct description is that if you = ask > for a variable and it is not defined, null value is substituted. That happens in the end, but not before an error is thrown. I want a = one-keyword way to know that a variable is not defined without having to = trip an error. > That's your opinion. Mine, for example, is that it is a very useful > feature. In any case, PHP is implemented this way, and there's no way = to > change it while the result remaining PHP language. If it makes PHP > unsuitable for you, sorry, but that's what PHP is. I don't think it > makes a lot of sense to discuss changing basic semantics of PHP engine = - > I don't think this is going to happen. At this point, I don=92t think anyone is proposing changing the = semantics of the engine, just filling a gap that lets one determine = whether a variable has already been defined -- like one can already do = for constants, functions, classes, array elements, and object = properties. You may or may not have use for the functionality, but other = people do, and adding a clean way to determine how PHP would regard a = given variable doesn=92t strike me as in any way promoting bad code even = if you don=92t personally use it. -Bob --Apple-Mail=_01B0878C-B4CC-4A07-9E69-4A9CBD151659 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
On Sep 16, 2015, at 11:28, Stanislav = Malyshev <smalyshev@gmail.com> wrote:

1 PHP defines null to = include variables that have "not been set" 2

No, not really, PHP does not = define that.

It does = according to the docs:

"A variable = is considered to be null if [=85] it has not been set to = any value yet."

=
I think that=92s more sloppy documentation = (declared versus defined) as opposed to literal truth, but=85.

PHP also defines null to = include variables that have been unset()

No, PHP does not define anything like that. In fact, unset() = means the
variable is destroyed and does not exist (of = course, excepting refcount
etc. issues). Null does not = feature in this story at all.

I=92ll refer again to the above = documentation:

"A variable is = considered to be null if [=85] it has = been unset().=94

This one can=92t= be chalked up to sloppy writing. Here, something is just plain = wrong.

All of the above does touch = on the gap, though. Ignoring the docs and looking at actual behavior of = PHP, it=92s clear that an undefined variable behaves differently from = one assigned null. One can easily tell if a variable is null, but one = can=92t easily tell if a variable is just not defined. That strikes me = as an oversight especially given the fact that one can use unset() to = make a variable once again undefined. Put another way, we can create and = destroy, but we can=92t identify existence. It=92s a small gap in = language design. There are workarounds, but they=92re = workarounds.

That's not a correct = description. Correct description is that if you ask
for a = variable and it is not defined, null value is = substituted.

That = happens in the end, but not before an error is thrown. I want a = one-keyword way to know that a variable is not defined without having to = trip an error.

That's your opinion. Mine, for example, is = that it is a very useful
feature. In any case, PHP is = implemented this way, and there's no way to
change it = while the result remaining PHP language. If it makes PHP
unsuitable for you, sorry, but that's what PHP is. I don't = think it
makes a lot of sense to discuss changing basic = semantics of PHP engine -
I don't think this is going to = happen.

At this point, I don=92t think anyone is proposing changing = the semantics of the engine, just filling a gap that lets one determine = whether a variable has already been defined -- like one can already do = for constants, functions, classes, array elements, and object = properties. You may or may not have use for the functionality, but other = people do, and adding a clean way to determine how PHP would regard a = given variable doesn=92t strike me as in any way promoting bad code even = if you don=92t personally use it.

-Bob
= --Apple-Mail=_01B0878C-B4CC-4A07-9E69-4A9CBD151659-- --Apple-Mail=_F2CA37B9-E7ED-4F0C-8ACC-FA2016460A94 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJV+csaAAoJEFBTSdRZ0ub3S8kQAKP31Kjzvk5q0vi9S5mIyOeM pNHgPrfWHZEwZNJ/Ea9JVkMac/YRr6CWtXUBlUseKcN4bMBXMCF6XWalZgd71/MX bJWOySrdYF1wugGF81Qv3Xv/wbaRvIMoc73fRNHr7/k9xKE01LC2byMrZ+Vlfctm JTtH1a4N8/QJgxm/SUMWwGJ0Ugx9M9Xv5jg9/hWomzs0wxYDOTVvswUTUv6vesh4 9eUSsbuYezCWaAHE/Ude+P+j0JCXF5mCHzxOyH3nCnHLQ5yKGbughf5mWo4V5D1S c/jGaz4emOEpeibJcivfYds0oYALH+13dZ5EH7AqAWZ/BnJtAsmgrDcaFUU5QT6o /LOR2BgfGk7LHKULxqjJLegpmkLeUNgC/8nXsSWgAyV0S+mAy0jdyYPJeCxCpvQX x6Mv0x7lahhURxovSLvebHoCM63h+gDSu8a7ug8JrAZMcO4K3tyaH6o1MlLSL2Sf W4Ap6pGJJN5UCtIGf8D0IQUZFj2ZWzA5XXRoCAY5hoTOQfHFLx2FRhwjgF7IeMr1 EZ00KuNYDnyRUbAPWVqZItxRQ1Y25vrU0nyfQnxZPZfZ5cz7EXHoGgiCQ3Pz0Wt4 ooiYFjIG06zRYExE+iEM0fqRXKQaPMmvwXgXg0h42pf/L5RcZu17dFcQPuLzGyoz js6ohGe42gamQRSLARkh =lUhm -----END PGP SIGNATURE----- --Apple-Mail=_F2CA37B9-E7ED-4F0C-8ACC-FA2016460A94--