Skip to content

Strict equality operator overloading for the \GMP class #13826

Closed
@Rafagd

Description

@Rafagd

Description

The GMP class already enjoys a lot of privileges in regards to having the language operators being overloaded under the hood to behave in a sensible way:

gmp_init(0) + gmp_init(1); // $x = \GMP { 1 }
gmp_init(0) + 1; // $x = \GMP { 1 }
gmp_init(0xFFFF_FFFF) & 1; // 0x1
gmp_init(0) < 1; // true
gmp_init(0) > 1; // false
gmp_init(133) == 133; // true 

This is all good but the strict equality operator is the one that behaves in a weird way. While I do understand it would be bad to have \GMP { 0 } === int { 0 } to be true, I do think it's very odd that gmp_init(0) === gmp_init(0) evaluates to false.

While I do understand they are different objects that have different pointers associated to them, I think this is just an interpreter implementation detail that shouldn't surface to the PHP user.

That kinda shuts down a more useful usage [IMO]: these are both the same number with the same type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions