Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88289 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62270 invoked from network); 17 Sep 2015 22:10:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2015 22:10:45 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:36985] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/B0-56569-46A3BF55 for ; Thu, 17 Sep 2015 18:10:44 -0400 Received: by wicfx3 with SMTP id fx3so8620033wic.0 for ; Thu, 17 Sep 2015 15:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=jNCZsrj+cKkZf4AYgRIIiOs6ApCH/zKy3npLuUGLhdc=; b=0uARyTl2Jza3lr1in1iYozHe02dqGM9Ii2UMHgr031qmpfwKRzWpsNw8Dv2h+8KhTO Ry2/4SWQ9uU2pNYNPwrEuidCujSP3Ok9VxzMHavfaG9A0Qtk6bEOS5a2cmy6XQdxXKtL IGbKC+JBd6a339fu3ClR3a0bBe/sRRJlmioOkvycOZIWzN9tRnGXBoCFonm2GamWOZC4 AH43/xZp5SXEbdm/7GJ6nUMLDQa/tgwM8CVwfA6wQwQsQwegPHZd5pdwT3ZI67iKVSid Ql5lDIyZn90Rbmj5ADkpUhd/dCCNOe10AxTGdxTVdRx2f7l0cOQ9Wm7hqdbebweDiTXw fyqg== X-Received: by 10.194.238.39 with SMTP id vh7mr2617212wjc.109.1442527841357; Thu, 17 Sep 2015 15:10:41 -0700 (PDT) Received: from [192.168.0.5] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by smtp.googlemail.com with ESMTPSA id i9sm5521758wjz.20.2015.09.17.15.10.40 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Sep 2015 15:10:40 -0700 (PDT) To: internals@lists.php.net References: <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> <440C64A2-4B4F-4AEF-ACE3-F3A6637EBAB6@thesba.com> <55F9D704.5050002@lsces.co.uk> <55F9EFA2.9020908@lsces.co.uk> <0022A1D9-DC37-4F49-B58E-FBED5AF872BA@gmail.com> <55F9FAB3.2050100@lsces.co.uk> <55FB19CB.7080707@gmail.com> <55FB3117.5040204@lsces.co.uk> Message-ID: <55FB3A60.1040601@gmail.com> Date: Thu, 17 Sep 2015 23:10:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55FB3117.5040204@lsces.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rowan.collins@gmail.com (Rowan Collins) On 17/09/2015 22:31, Lester Caine wrote: >> To paraphrase, your 3 states being communicated from the controller to >> the view are: >> a) Do not use this object, even if you want to. > EG Vehicle is not old enough to need MOT > >> b) If you want this object, you may create a default one. > EG No current MOT found > >> c) If you want this object, create it with these parameters. > EG Display date of MOT ... when next one due should not be stored here, > only when one is added. This is an entirely arbitrary mapping. You actually have two pieces of information you're trying to fit into one variable: - the MOT status, out of "not needed", "no current MOT", "has current MOT" - the details of the current MOT, if one exists That's what I was getting at with my "variable colours" example - if all you're after is "a variable with 3 states, one of which also allows a value", that's not really anything to do with exists() and isset() any more. It would be a convenient use of that state, except that that state isn't convenient to use, so why try? This is also a perfect example of why co-opting states like null and unset for complex meanings is generally a bad idea: what if in future, you need to distinguish a 4th case of "never had an MOT"? You've now used up both NULL and !exists(), so you're back to square one, and need to petition for some other piece of variable metadata to be exposed - or give up and change the implementation to use a separate state flag. >> You then want to use null for case (b), so need a "very null" value >> (non-existent variable) for case (a). > Database takes care of managing the business logic to ensure data is > consistent. One could use an invalid date for 'NULL' but these are not > consistent between database engines ... NULL is. Reading CAR data does > not return an 'MOT' record while it is not needed. 'MOT' does not exist > flags logic to display 'first MOT due' from registration date. Putting a > date in the 'MOT' field is not the way to handle that. > > The business logic in decent databases like Oracle and Firebird rely on > NULL for many reasons, and while one can return more fields to handle > the 'three state' model, NOT returning a field is faster. MOT is crude > example, on council systems several sets of data may interact, and the > NULL state is significant. You keep defending your use of NULL, but that is not what needs defending; it is the proposed use of an unset variable as a "very null" state which I am questioning. As far as I know, most databases do not have the notion of "does not exist" in tables or result sets - the result of a Left Join failing is the same type of Null as can be stored in a Nullable column. Regards, -- Rowan Collins [IMSoP]