Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104962 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78530 invoked from network); 27 Mar 2019 02:16:27 -0000 Received: from unknown (HELO mail-io1-f48.google.com) (209.85.166.48) by pb1.pair.com with SMTP; 27 Mar 2019 02:16:27 -0000 Received: by mail-io1-f48.google.com with SMTP id x7so12419874ioh.4 for ; Tue, 26 Mar 2019 16:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ztQY41m4aTeqtcKXIzT1/znol5lZPjkFrSC8cw5X3V4=; b=hEGHOuqNeMjeDB9iaUySMw6iWPrjgtijjt6foHAnyAwqBpvZErZTb8hnsXOMrRiaO8 O3+/+KBtzk7ci2CQvjPq0RXoqKuLWdo9lAdXwX+kNEIdxzUOE13pQjRJx7RqKKNP6Szr adgKcGOZLjuYHAD/HTIm8JFjp+oe5pZK2k1uzIfKh/3k8dhiRhYgD3dbzadt8Tyz1Z3l 3tgLczECHSd90pdmcFc3GF+I/KwxNlX7iYwz4PAoSbVPhVzLg2MnsdPlH6QKG6NISlO1 AqBFGGRje1+3yc6VDIquUxCAoIGRrrLqEIICrW0MYz4kyGD1KpnaecEm+SV266PalBcR 9+Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ztQY41m4aTeqtcKXIzT1/znol5lZPjkFrSC8cw5X3V4=; b=d5IPd6scnprh8Ln8inbu7Xn8D9lbGUT7SdbI1h9UKFFWZ9fXSrecOb/ld7Vb8btSjA RSxb1jCTT09/MluHLi/rHWjC0poRBrXrOSL/urMnYRfjAkauF9DcAu1b3L6KbRh9dWBC /Yoqo26uUB1jHCxpPApOYdQJtKtJTVRLPFRDMy0JFquhXu6hO/moj//qjrMMmckKVdwc tBKB1B7nIm8HtrUrq+fDQZ9DTorAxTepRSlI2cAhrUpM2zdZEzYYxZyF5RY6ULTumGV/ /w98ksmj8JF4GcN0Im8zmH/xlfK8AG8PZ0Yp5M9KSDwe6l9LkZAB4L/0nzNFlqN3jBHA Wung== X-Gm-Message-State: APjAAAWJ4tMuL/XxfE6MAixwgwsJP3Sg/09lfY/7/NswCF0FFOsI9Wn3 jq9JvrHRZ+OZ6RBAtGACoUBjEOHoEdzGDRegqOc= X-Google-Smtp-Source: APXvYqyiU9/XzRZGS4O51mlLTgNdxHgUiZ7ToMH5EJZuWenCn88pCUX8LCY7pCkVVBnZ3BUgGBipEgi3DGYTSh1gcgo= X-Received: by 2002:a5e:a60c:: with SMTP id q12mr24317525ioi.174.1553641796565; Tue, 26 Mar 2019 16:09:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 27 Mar 2019 00:09:44 +0100 Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000647d600585076bff" Subject: Re: [PHP-DEV] Re: [RFC] Permit trailing whitespace in numeric strings From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000647d600585076bff Content-Type: text/plain; charset="UTF-8" > > You might want to have a stiff drink before reading through the examples > in this RFC then: https://wiki.php.net/rfc/string_to_number_comparison I've already browsed this RFC, I think it's a step in the right direction and agree with it for the most part, with 2 exceptions: - the one we're taking about here: disallow both leading AND trailing whitespace in numeric strings - I would also strongly suggest that 2 strings are always compared byte-by-byte; IMO it does (*somehow*) make sense that 42 == "42.0", but it DOES NOT make sense that "42" == "42.0". I mean, when you're comparing a string to a number, surely you expect some kind of conversion to occur in one way or another, but when comparing two strings, why this magic? Is that because we want to enforce IF ($a == $b) AND ($b == $c) THEN ($a == $c) ? If so, I would push this RFC one step further towards strictness and suggest that: ```php var_dump(42 == "42"); // true var_dump(42 == "42.0"); // false ``` Which would meet this enforcement. I come across code that benefits from automatic conversion between an integer and its string representation every day, but have yet to encounter any code that would benefit from quirks such as 42 == "42.0". Getting an integer as an int or as a string is no big deal, but as soon as you start dealing with decimal strings (and floats), you're asking for trouble if you're relying on such quirks if you ask me. Also, may I suggest that these 2 RFCs be merged together? https://wiki.php.net/rfc/string_to_number_comparison https://wiki.php.net/rfc/trailing_whitespace_numerics Ben On Tue, 26 Mar 2019 at 23:28, Rowan Collins wrote: > On 26/03/2019 21:54, Benjamin Morel wrote: > > I almost had a heart attack after running this code. I knew that PHP had > a > > few quirks when comparing different types, but I had long taken for > granted > > that comparing 2 *strings *performed a byte-by-byte comparison. > > > You might want to have a stiff drink before reading through the examples > in this RFC then: https://wiki.php.net/rfc/string_to_number_comparison > > Regards, > > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000000000000647d600585076bff--