Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126995 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 E579D1A00BC for ; Tue, 1 Apr 2025 07:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743493124; bh=lv+By9WfSDvdfeWIc12UDoc3XNryAgSuJV+GW7Ut13o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jlmmuii22foE6UMSVL3ednolkTChcOAych6gKhbsxrXHU+PflIqZtb2K4g7sjwvVb XYarJTYhmuEAG735+Eq4O25MSiFI9RPB0DPdhkkjXr1KayM6IY58S8AMEfW+r0Z5Qo ZhhUaYMIQMJUenEVgThczb+UIH8Rq3Kj8uB31Cq0SnbAijJ/RLM6dAcS9YKADxrR+T AeVMrwy1sArBhADG8T1uIpj4EitY7UR2m+BVqsUTw+y9bNj9JZmmTp2uaUgo1lTrPq XmXtN6B8VVDwm25nqSK23lxSGQ02bct8nEUw+wODFsgwwjsyR6CpqWhxbcuLmvvj8V /OFmRxM2EzG8Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 96DB1180034 for ; Tue, 1 Apr 2025 07:38:39 +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-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 07:38:29 +0000 (UTC) Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-ac28e66c0e1so783053166b.0 for ; Tue, 01 Apr 2025 00:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743493255; x=1744098055; 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=lv+By9WfSDvdfeWIc12UDoc3XNryAgSuJV+GW7Ut13o=; b=Wn5Rm3Rk23plZIy//1lN5148PjWFV81AMN+Ndz9A/NZNJ4BvnPX2SiBnCr8OfHKYKx lpxqtqzmcA5HMj4vngpTPToStUV56FpWTubuKF7+aR850npr27fSZrasZIDGtAsFF5v+ Emryd2KafuO2Z4xRjlYIZeNUi6FrhOnvqj9YGEpoCb39aPdmaMfyX7QJBzcYu8QsvPeM vPEqatfYqgakHJwThqI6dXXnGZy8bJLE1q2U318XxvRScCxA/sRij4HqhMrzSpOWpySK 9KzOjgcUYaVGXIsyQybbTZ5hVmkCcyVxxBYRppRoxPddcVCSY5hGsuBpSW5i7uaj+hSO gbQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743493255; x=1744098055; 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=lv+By9WfSDvdfeWIc12UDoc3XNryAgSuJV+GW7Ut13o=; b=ssokvbm79ZhxxKuriQ21oOJcqky1bYJGunc5ot55w1tdimJbTtnUt18Wj+vD2CXbho 6h4oGBfZ1D7aZHpM9RZRX/2rNQ3qKnT81+AwRJWZ0vealvqA2g3MC50B/niuvHRngSXP 92WslBYnWQVkQ63o2sltUNhD9IPvxrQR47YBxZj+k+NvDGcxziO6Yi6NyBLHbnRLWPny VW/2Oh1/TRWXCCa1FYhK7qW2i8/ufb8R0IFRYZowdy/cyhKEICBOcZX6QjKBYD4wQU4s 6wzZkh4B2gxwx8Kkc5Z8lZnS0qcqmgd02b/epgMOLOtWbaJrKNtbfMAz2i71QUr+H459 0ybQ== X-Forwarded-Encrypted: i=1; AJvYcCXedsp+4YeuCKr04alEakm/FKOilutyPmIWSqDpLKMPm/cTYsYskzBxmxspWSQ26KX5GUzSrvprlkI=@lists.php.net X-Gm-Message-State: AOJu0YxaoEWdHSZdaN/t0A/mDkKUt4f88ufbDx0mfouEU+MDBxFySUNI tcbzJqXHekbQbuhVUTAbjrkoD+vaZf1mQVdwaMWYQNJoWQJ1KseyEsp4JaZWFTUgVrMv8JeiHme gxmEHKP5d5rWGnl/xiRnU14N2fVYtccLkagM= X-Gm-Gg: ASbGncsiBRal/0BnhUSRMmpeA+yJqzSW1JRpOWBFogQnpkZym/nF464DI5IBBD1U6/p w9S9YT9f3xukkVWLugGNh4LFMDAj5Em+uewp5K4+mpGezYduH4ZKXytcIRFqTcQM4hEstlpplSv 5t2Wm/vuIW+2AeXVNVrEGZAW0k3g== X-Google-Smtp-Source: AGHT+IGAUgF82ezD4uAYcwpCgdjQ0IM8ZcJ3/rs4de4bc3Ygq9WMk+dBzitjeYZ8x0Dmu9Oodd7DTxMEHxyeaOIGHOY= X-Received: by 2002:a17:906:c106:b0:ac3:422a:76dc with SMTP id a640c23a62f3a-ac738adef63mr980195766b.34.1743493254732; Tue, 01 Apr 2025 00:40:54 -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: Date: Tue, 1 Apr 2025 10:40:43 +0300 X-Gm-Features: AQ5f1Jrwe_2EfNkW-lN13eaL4hCsRhrm9rp8EUyQ_oXf1ISjvSA0R3-cjGsPXbQ Message-ID: Subject: Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: Niels Dossche , PHP internals Content-Type: multipart/alternative; boundary="0000000000001de1b50631b2a8fa" From: i.miroslavov@gmail.com (Iliya Miroslavov Iliev) --0000000000001de1b50631b2a8fa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > var_dump(random_int(1, 1) ~=3D 1.1); // true This one cracked me :D Thanks Niels! On Tue, Apr 1, 2025 at 5:48=E2=80=AFAM Alexandru P=C4=83tr=C4=83nescu wrote: > > > 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 neithe= r >> `=3D=3D` nor `=3D=3D=3D` are ideal comparison operators to deal with the= se 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 > also remembered today it's 1st of April, so there's that... > > -- > Alex > --=20 Iliya Miroslavov Iliev i.miroslavov@gmail.com --0000000000001de1b50631b2a8fa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
=C2=A0> var_dump(random_int(1, 1) ~=3D 1.1); // true
This one cracked me :D Thanks Niels!

O= n Tue, Apr 1, 2025 at 5:48=E2=80=AFAM Alexandru P=C4=83tr=C4=83nescu <drealecs@gmail.com> wrote:


= 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


--
Iliya Miroslavov Iliev
--0000000000001de1b50631b2a8fa--