Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126992 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 42D7D1A00BC for ; Tue, 1 Apr 2025 02:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743475383; bh=AuMqyYj/tftzW1L+GhlyUAX988uk/wXpwGrZjn5EvCI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eoe6BwtwIkBRTORk+8FX1nY2/pbdh3LcB7uxgeHFx/MSZtY3R55o4fiLjdRVPhdzt OhCyCaKCgENIMQEMz5O1pBZrJ97EO/TIMtx1zoI8eB2iXz2e2ewFwoX4JjfWiRhbvN RWdRUKIpEc46XtGk5hPjelvOZNdQrYLNQ9zmZMy4DTu8YhSkCI1EvpUQXdK00NdTOL XfWqNEyyPuA+tGNVCo5Y/+M55YcR0ZeiYqCfAaacIKVGRY/VYzJwAL09YxKGQnnTtK /9OZTm/2X3bn46uaVEzHnn2P3xNbGflQqDsv1QvqrQu0odGfq8CF1VPA9aYEOt9bT2 lCf9GkF7fVGiw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D231418006A for ; Tue, 1 Apr 2025 02:43:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 1 Apr 2025 02:43:02 +0000 (UTC) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-6ff27ad48beso47101497b3.0 for ; Mon, 31 Mar 2025 19:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743475529; x=1744080329; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=AuMqyYj/tftzW1L+GhlyUAX988uk/wXpwGrZjn5EvCI=; b=J9tl9sD1OnV/ByFzqo+z+0fwg800E0mXsIuCOEkzv+8HWjj1kYjND2SCjFnrjOPBLQ DUrulfle6qZooDq4rUGiTCE3RPtbtDmtc2j5T4tgKFEvmsS7BUmTM/bQbBcTQ9x+OeCc vj2qgwpePc1CU69eGLnyizDLOTw0ekvWBQPmAhCg4NvK/qSiwloLnI1/leuiMNg4CYUO 3yVwnlZaRVm3QmxnquMNF5/45vhKVcjGayB4U+zA1z9X6LZ1XsII6Mppg4NgTim/ErtI hou73PkES3+yhOecolpWxQOy9O2IJSdag5NqzDdHrPcUJoiCj7ovxHShEz7xCOtTheRo /dCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743475529; x=1744080329; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AuMqyYj/tftzW1L+GhlyUAX988uk/wXpwGrZjn5EvCI=; b=gzSwYczrc3KUWA5YbTPyCb+aLqBq59sdAN6+f7pl7UMZwePm+0XY60EEt4o4z1nbik 2yaTI4P631vzGxnLcN9Zf0pnIsPBG6/Bu0UtQT3wv/ezdYzMwEMfcuS22pLFZdELQer6 +ppC1uO58i/gtkQIm3jnPPM6ZR4KnUW1pWoMVnuOexoKdfO9jZ9S056aCPjZZn1uftvu vXoQigm5iThK3lDW+myD9NXezf7SSZsMEJo5vJbkL0r2H3OTEcoaUeATOcvjXlB21ibm UoClEo9I+2Mhojmp9kOu4sIO6s+8fMj74+iQku1qWV6z5jHM/QdihPOSmUdeSSizInXv qfrQ== X-Gm-Message-State: AOJu0Yyi2RYnTWdI+gKvHRyTfpinK4OuGXjMmEP7FS+utGbh99qxBElR KlaP8ESd1h4XStG/FWVL0wHfqrj9qL57NxrmjEoTHCpFCBYq96icZcrjJA2pFJxzZBrTpjRjlVd 4J816nSCRaCLJOnig16DejEaSMUCY/LDa X-Gm-Gg: ASbGncsQWRd74JPalTwnj//e+IYp3Adi1UdICQWfPRnIxkXwxEMLic62y6BNONV0Jfk /FaJYM2nxt/246sO6OWOSiVrYxszGHsoIuOkxhv6VVJK5foAGaNcvrUtwuOzv+mDSJnTg0784JC 2puqEnuC/SIyqAmc88KNaR8WlF824= X-Google-Smtp-Source: AGHT+IERpFOPlxEVmCDv5vK7wsf2iPYll7BPQaYDpaBPtNl0ovsLiJPURAzWjmUC+v0yUgkKjbW9qwnfbGiiXU4Lbtc= X-Received: by 2002:a05:690c:4883:b0:6fb:b37f:2072 with SMTP id 00721157ae682-7025710c124mr167224347b3.22.1743475528699; Mon, 31 Mar 2025 19:45:28 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <4a3c6ce7-102d-4cfe-a7a8-35630715b870@gmail.com> In-Reply-To: <4a3c6ce7-102d-4cfe-a7a8-35630715b870@gmail.com> Date: Tue, 1 Apr 2025 05:45:16 +0300 X-Gm-Features: AQ5f1JojOh1qo57_MbzLSkckHz_jcFSrI_UeG0gWQq_jIgF2xdPSefIkrjxk56M Message-ID: Subject: Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator To: Niels Dossche Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000901a690631ae875a" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000901a690631ae875a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 1, 2025, 01:03 Niels Dossche wrote: > Hi internals! > > I'm excited to share what I've been working on! > I had an epiphany. I realized what we truly need to revolutionize PHP: a > new operator. > > Hear me out. > We live in an imperfect world, and we often approximate data, but neither > `=3D=3D` nor `=3D=3D=3D` are ideal comparison operators to deal with thes= e kinds of > data. > > Introducing: the "approximately equal" (or "approx-equal") operator `~=3D= ` > (to immitate the maths symbol =E2=89=83). > This combines the power of type coercion with approximating equality. > Who cares if things are actually equal, close enough amirite? > > Hi Niels, When I was reading it, I felt a bit unsure, but numbers related, it was making sense. When you got to strings with `"This is a tpyo" ~=3D "This is a typo"`, I al= so remembered today it's 1st of April, so there's that... --=20 Alex --000000000000901a690631ae875a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Apr 1, 2025, 01:03 Niels= Dossche <dossche.niels@gmail= .com> wrote:
Hi internals!
I'm excited to share what I've been working on!
I had an epiphany. I realized what we truly need to revolutionize PHP: a ne= w operator.

Hear me out.
We live in an imperfect world, and we often approximate data, but neither `= =3D=3D` nor `=3D=3D=3D` are ideal comparison operators to deal with these k= inds of data.

Introducing: the "approximately equal" (or "approx-equal&quo= t;) operator `~=3D` (to immitate the maths symbol =E2=89=83).
This combines the power of type coercion with approximating equality.
Who cares if things are actually equal, close enough amirite?


Hi Niels,<= /div>

When I was reading it, I= felt a bit unsure, but numbers related, it was making sense.
When you got to strings with `"This is a tpyo" ~=3D &qu= ot;This is a typo"`, I also remembered today it's 1st of April, so= there's that...

--= =C2=A0
Alex
--000000000000901a690631ae875a--