Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104521 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49928 invoked from network); 26 Feb 2019 16:19:53 -0000 Received: from unknown (HELO mail-io1-f47.google.com) (209.85.166.47) by pb1.pair.com with SMTP; 26 Feb 2019 16:19:53 -0000 Received: by mail-io1-f47.google.com with SMTP id x4so10427576ion.2 for ; Tue, 26 Feb 2019 05:06:17 -0800 (PST) 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; bh=CAxZazoz2dNOHsCM8AnZT5mcb7yz1RXKZe1qBxXctpU=; b=DqbMI8e5unwAIWpqp5z4z1OcYaWe8Y/AXlA6ow8rawcn7YIFOOqlWahcZDq+q1Nn1F bZg9SQLQZ8LpZOVPf8p+axOg1srJu+e8MVTLuizHuo8wrpWf/T805+psTTKP1tpPxm7e eyqSOoXN+PNebWbDn/lmQ+zB1RKWYW/HIX5TD1BRK8ZlyBnJ/uo6acZ1qD7BsgkiLR+5 NgMz70G3qGTQawvpstzwlKbdaOfNLLeRu52JFT+VqZUI1TYco4/POXl7zUz7hD5JKjQ8 3a7W5Zbnezouuu0MxiBoWla5DKgW9N6AYStRVa1RzTeWW+DFfvqwHB7Q+hmQvNkfftP9 2OsQ== 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; bh=CAxZazoz2dNOHsCM8AnZT5mcb7yz1RXKZe1qBxXctpU=; b=n2uJcTi/rSr2u/IQE1T+PZpKuavPzq3cMA3MWgBCepjdQLXKIb4et/kmsiBg20iA4l nOvlBvG97tOnxaugYueexNg3GZ5gwZSEKLVcG/29Ae100ovdXx6HeEUi9HlISpbNuJJ9 Ie403itd5ZwtaCrhzMWDMxO+TTlOoBPb0HUSyDC1UB97Eaw+7mItob+hJ8nr87F/xMUZ eK81uJ1586P7sg9AiXeDcVgOztbadhdV+xeV5UXlFildKZ0728vW9lHdmezdRoo1OPd+ sXfqRJGn3GOb1HbCekR/IMUv4G4dEMMDQObeFOhQd6eAu25g3yd8zwLV6Pl/4CDjuN1p Tfuw== X-Gm-Message-State: AHQUAuYTrZFR6VH0aOJxj4NFhdBe6HGlYGdDe3lRM+XmwT5tHXs2fz3j p26NN3TWYHvEc17wVGIYU0P+Q5FZsHO6rRPjQI5T77Qr X-Google-Smtp-Source: AHgI3IaKMNK0PyA2vWHybCSJPq98gKhMks47VBoJkZ12xGN1cSeyqRRp9DMFuzrybsThNcaYJ8Krm/q8YhzdStXv5B0= X-Received: by 2002:a6b:e514:: with SMTP id y20mr11256262ioc.235.1551186376540; Tue, 26 Feb 2019 05:06:16 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 26 Feb 2019 13:06:05 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000f447ad0582cbb8be" Subject: Re: [PHP-DEV] [RFC] Saner string to number comparisons From: rowan.collins@gmail.com (Rowan Collins) --000000000000f447ad0582cbb8be Content-Type: text/plain; charset="UTF-8" On Tue, 26 Feb 2019 at 12:27, Nikita Popov wrote: > I'd like to bring forward an RFC for PHP 8 to change the semantics of == > and other non-strict comparisons, when used between a number and a string: > > https://wiki.php.net/rfc/string_to_number_comparison > Hi Nikita, Thanks for tackling this; I think if we can improve this, we'll be answering a lot of language critics (I'm sure they'll find something else to complain about, but that's life!). However, I'm concerned that it doesn't go far enough, when you say that the following will still return true: 0 == "0e214987142012" "0" == "0e214987142012" I think the cases where this is useful are vastly outweighed by the cases where it's completely unexpected, and potentially dangerous (e.g. in a hash comparison). If this is not fixed, the "dogma to always avoid non-strict comparisons" you refer to will remain. If I understand it right, this arises from the fact that "0e214987142012" is considered a "well-formed numeric string", which is cast to int(0) or float(0). Is it feasible to also narrow this definition as part of the same change? Regards, -- Rowan Collins [IMSoP] --000000000000f447ad0582cbb8be--