Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-05 Thread Derick Rethans
On 1 April 2025 20:52:32 BST, Larry Garfield wrote: >On Mon, Mar 31, 2025, at 5:03 PM, 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

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-04 Thread Tim Düsterhus
Hi Am 2025-04-01 00:03, schrieb Niels Dossche: We all had situations where we wanted to compare two floating point numbers and it turns out that due to the non-exact representation, seemingly-equal numbers don't match! Gone are those days because the `~=` operator nicely rounds the numbers for

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-02 Thread Jordi Boggiano
On 01.04.2025 00:03, Niels Dossche wrote: We live in an imperfect world, and we often approximate data, but neither `==` nor `===` are ideal comparison operators to deal with these kinds of data. I am late to the party here, but in all seriousness when I read the subject my initial thought wa

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread mickmackusa
I love April Fools jokes. Yes, and let's add the null coalescing increment and decrement operators: $foo??++ and $bar??-- . I want to ensure that an undeclared or null variable defaults to 0 before becoming 1 or -1 without needing to manually instantiate the variable as 0. Pfft. --- Anyhow, wh

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Rob Landers
On Tue, Apr 1, 2025, at 22:17, Derick Rethans wrote: > On 1 April 2025 20:52:32 BST, Larry Garfield wrote: > >On Mon, Mar 31, 2025, at 5:03 PM, 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

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Iliya Miroslavov Iliev
On Tue, Apr 1, 2025 at 11:29 PM Rob Landers wrote: > On Tue, Apr 1, 2025, at 22:17, Derick Rethans wrote: > > On 1 April 2025 20:52:32 BST, Larry Garfield > wrote: > >On Mon, Mar 31, 2025, at 5:03 PM, Niels Dossche wrote: > >> Hi internals! > >> > >> I'm excited to share what I've been working o

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Larry Garfield
On Mon, Mar 31, 2025, at 5:03 PM, 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

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Iliya Miroslavov Iliev
On Tue, Apr 1, 2025 at 9:14 PM Rob Landers wrote: > On Tue, Apr 1, 2025, at 15:06, Iliya Miroslavov Iliev wrote: > > Claude, in your example if `var_dump(false == true);` is `false` what is > `true` in this world? It is `true` that `false` is not `true`. > > On Tue, Apr 1, 2025 at 3:39 PM Claude

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Rob Landers
On Tue, Apr 1, 2025, at 15:06, Iliya Miroslavov Iliev wrote: > Claude, in your example if `var_dump(false == true);` is `false` what is > `true` in this world? It is `true` that `false` is not `true`. > > On Tue, Apr 1, 2025 at 3:39 PM Claude Pache wrote: >> >> >>> Le 1 avr. 2025 à 00:03, Nie

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Iliya Miroslavov Iliev
>IMO a step in the right direction, but it doesn't solve the problem that >the developer might not even know which equality operator to apply. >Thus, I proprose the whatever (?) equality (=) is right (->) here (!) >operator, e.g. You mean something like: ```php function str_aprox(ClientData $_, st

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Christoph M. Becker
On 01.04.2025 at 00:03, Niels Dossche wrote: > We live in an imperfect world, and we often approximate data, but neither > `==` nor `===` are ideal comparison operators to deal with these kinds of > data. > > Introducing: the "approximately equal" (or "approx-equal") operator `~=` (to > immitat

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Iliya Miroslavov Iliev
Claude, in your example if `var_dump(false == true);` is `false` what is `true` in this world? It is `true` that `false` is not `true`. On Tue, Apr 1, 2025 at 3:39 PM Claude Pache wrote: > > > Le 1 avr. 2025 à 00:03, Niels Dossche a écrit : > > Hi internals! > > I'm excited to share what I've b

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Claude Pache
> Le 1 avr. 2025 à 00:03, Niels Dossche a écrit : > > 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. > > [...] > First of all, if `$a == $b` holds, then `$a ~= $b` obviously. > The t

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-04-01 Thread Iliya Miroslavov Iliev
> var_dump(random_int(1, 1) ~= 1.1); // true This one cracked me :D Thanks Niels! On Tue, Apr 1, 2025 at 5:48 AM Alexandru Pătrănescu 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 r

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-03-31 Thread Alexandru Pătrănescu
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 neith

Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator

2025-03-31 Thread Bilge
On 31/03/2025 23: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 `==` nor `===`