Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96051 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30949 invoked from network); 21 Sep 2016 12:49:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2016 12:49:35 -0000 Authentication-Results: pb1.pair.com header.from=vpkaihla@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=vpkaihla@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.53 as permitted sender) X-PHP-List-Original-Sender: vpkaihla@gmail.com X-Host-Fingerprint: 209.85.215.53 mail-lf0-f53.google.com Received: from [209.85.215.53] ([209.85.215.53:36145] helo=mail-lf0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/83-04117-CD182E75 for ; Wed, 21 Sep 2016 08:49:35 -0400 Received: by mail-lf0-f53.google.com with SMTP id g62so39567728lfe.3 for ; Wed, 21 Sep 2016 05:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p21wXM71U8hxGATl0OW/XIBv4hlTtgVWh3HYY+dZW78=; b=mosUhGuTIaqlsIEcO30lm3xY26sSmZwSDJfmVN7YKzxxXMoNbTFoacL9p5foVg1EhS iea+5trAfQZiHUWbX9nlbMxnXDvHWDWsUycYdBFcmnqNQ3cpPzKK63SYgew+O8XnyxLa ZbDMI3i5HlN7jRnDl652D9gbFRW/vwcl2gLMc2FVtX6c3d4xoaWofOSjcSqinHaTNF2o H3aGN2zQaayp/SBVqJlpW064fXCZTQJ23PUF8enVnLekAln2E/qGIC2Pkkx91U6Evd2O tQp48LgcNNhoBCxeHqaKZdR5m44iCeTThovlz6DtwObNV+9AKgfoVvIFZ/k9de1jig3v tVvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p21wXM71U8hxGATl0OW/XIBv4hlTtgVWh3HYY+dZW78=; b=FIAD1KmI6uHkLTkxakm6apm2QMYDa63mMplegrbSL9cPqJUpQGTgGSooE33SSF3xAX usZg15beZirwaQrWPpKvv7RXVdApqu5xm1fXx7/lfDw7tc8AelArd9OqlXNI2a7DVqST ByzO6MXjsCphXlir7QNA+V6QwOfi+kQc73F76SABBjOUIyVC/FYeAgMZDnpcJgR0oV8D JPoEIdb6RpO4KKqmOkdwtCPANFZeJu7NSZCUwVrmMDxN3QaLbWa7PTLt/CPbyRKM7z/S XWwO6j/bdGsR59SOIsUFLbpPzD9ArQ8oH5LVX8aySmxvxYgmAYAdl9iV6I7mdSTzNAKv 3p4g== X-Gm-Message-State: AE9vXwMD18oXtGpsgM+XoYvVgh41t+CZ6jlG2np0XBfo5HpjejutgCt50wFCNDMb0rkCN70Ybd62qr2KxOux7g== X-Received: by 10.25.18.157 with SMTP id 29mr13989305lfs.10.1474462169609; Wed, 21 Sep 2016 05:49:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 21 Sep 2016 12:49:18 +0000 Message-ID: To: Dan Ackroyd Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113fbf04daf663053d03f98b Subject: Re: [PHP-DEV] RFC: Strict comparisons From: vpkaihla@gmail.com (Vesa Kaihlavirta) --001a113fbf04daf663053d03f98b Content-Type: text/plain; charset=UTF-8 On Tue, 20 Sep 2016 at 02:20 Dan Ackroyd wrote: > Hi Vesa, > > On 19 September 2016 at 14:04, Vesa Kaihlavirta > wrote: > > > > My idea is to add a strict_comparisons declaration that you can add at > the > > beginning of a file in the same way as strict_types. > > > > Please take a look and let me know if this would be worth a more official > > RFC. > > I think it deserves an RFC. > Cool! I'll write some more unit test cases and start working on the RFC text. > > One thing that might make people hesitant about this, is that it's > likely that you would want to have the occasional weak comparison in a > file. > > However that should mostly covered by just adding a cast where needed > presumably? e.g. like: > > $foo = '5 apples'; > > if ((int)$foo == 5) { > echo "eh, close enough"; > } > Yeah, that works. I added that as a test case. What still worries me personally is ===. What do you think would be the least incorrect way to handle === (and other identicality operations) when strict_comparisons is in effect? I thought of the following options: 1) === works like ==, that is, makes type checks and throws exceptions if the types don't match 2) === is not affected by strict_comparisons. It would then be *weaker* than == when s_c is on (since it would just return false instead of throwing). That would offer a sort of a convenient way out of the strictest comparison mode, but might be confusing. 3) === is disabled/not allowed when s_c is on. Would lessen the risk of confusion. Thoughts? --vk > > cheers > Dan > --001a113fbf04daf663053d03f98b--