>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 $_, string $value1, string $value2) {
if ($value1 ?=->! $value2) {
return (bool)random_int(1,0);
} else {
return (bool)random_int(0,1);
}
}
```
This sounds reasonable. I approve!
On Tue, Apr 1, 2025 at 7:16 PM Christoph M. Becker <[email protected]>
wrote:
> 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 immitate the maths symbol ≃).
> > This combines the power of type coercion with approximating equality.
> > Who cares if things are actually equal, close enough amirite?
> >
> > First of all, if $a == $b
holds, then $a ~= $b
obviously.
> > The true power lies where the data is not exactly the same, but "close
> enough"!
>
> 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.
>
> $value1 ?=->! $value2
>
> I leave the trivial implementation as exercise to the reader, while I'm
> porting the even more powerful rmmadwim TCL command[1], which,
> incidentially, also had been proposed on an April 1st.
>
> [1] <https://core.tcl-lang.org/tips/doc/trunk/tip/131.md>
>
> Christoph
>
--
Iliya Miroslavov Iliev
[email protected]