Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111019 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2549 invoked from network); 15 Jul 2020 14:46:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jul 2020 14:46:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A20611804F2 for ; Wed, 15 Jul 2020 06:39:33 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Jul 2020 06:39:30 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 90948B7F for ; Wed, 15 Jul 2020 09:39:29 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Wed, 15 Jul 2020 09:39:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=fr+TAx HJrhEGvJpeptpIfj67MLgm7E4+BKoe6pdjekw=; b=owah+BV3EnJdMmQYX2CWJU 8NcEQM/rZifEdrpILPmGAuOD4b++yRuNRrlH0TzOjlJjJwD0NU9X0OT8jnk70wjy +kd3cT1USJGNUy6CsFSsB5MbJ8Aroatia481Z2ZAoUyj74ejMhJdpV5m76UaZ/sj ZHdPM9ngbXGQxuI0ynJMcl/LacExj2U6Z9roQ8RZakklnnLnClwGzYNantjjPIFP tCkbofBy4kCDFxjX1flFfra6rKNL/jls9jdABxGpcZ4gBYbvK11hgHk91EA3ch+L 70W8aUD5fqcMEufgfBYaQbSiQvRgAU4K+7JqFW5yDFMVn4Gm9T2Eg38krrWDoWrA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedvgdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeegheff gfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgv lhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6DA8614200A2; Wed, 15 Jul 2020 09:39:28 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-dev0-613-g8a73ad6-fm-20200709.001-g8a73ad6e Mime-Version: 1.0 Message-ID: <132a2f9c-331c-48c9-8c15-f0f7c9392341@www.fastmail.com> In-Reply-To: References: <21C5073D-3F39-49DA-8686-E027AE780793@joshbruce.dev> Date: Wed, 15 Jul 2020 08:39:08 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC][Discussion] Objects can be declared falsifiable From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 14, 2020, at 11:48 PM, Matthew Brown wrote: > On Tue, 14 Jul 2020 at 19:59, Josh Bruce wrote: > > > Implement an interface and magic method to allow objects to represent > > false (or empty) while still be valid instances of the custom object (type). > > > > https://wiki.php.net/rfc/objects-can-be-falsifiable < > > https://wiki.php.net/rfc/objects-can-be-falsifiable> > > > > If you saw the latest from this morning, not much has changed except > > hopefully improved formatting and now being the official mix of things. > > > > If this is your first time, the cues are taken from: > > > > - __toString() > > - Stringable > > - and __toArray() (not accepted or approved yet) > > > > Thank you for all the feedback and patience so far, appreciate it! > > > > Cheers, > > Josh > > > I'm not sure I love this (mostly from a static analysis standpoint). > > It means that there would exist some `$foo` with the property that `$foo && > !$foo` evaluates to true. > > That seems to be a bad place for a language to go, and it would increase > the false-negative rate of static analysis tools. I don't see how that would happen. What non-pathological case would allow for $foo && !$foo == true? (I know you could do something stupid like return random_int() from __toBool(), but I'm ignoring that as "you're dumb so of course your code is dumb.) From the RFC, I don't quite get this line: "Further, the union type bool|Falsifiable will be dynamically added at run time to any object implementing the reserved __toBool() method, which would allow stdClass() objects to be defined as Falsifiable also. " What's that about? "(Including __construct() replacing old style constructors in PHP 7.)" - __construct replaced old-style constructors in PHP 5. :-) I think the truth tables have a formatting error; check the last line that goes wider than the rest. Also, watch out for "smart quotes" in the string parts. Also, YAY summary tables! --Larry Garfield