Skip to content

Refactor == operator to support generic numeric equality#134

Open
yabuz87 wants to merge 2 commits intotrueagi-io:mainfrom
yabuz87:main
Open

Refactor == operator to support generic numeric equality#134
yabuz87 wants to merge 2 commits intotrueagi-io:mainfrom
yabuz87:main

Conversation

@yabuz87
Copy link
Contributor

@yabuz87 yabuz87 commented Feb 24, 2026

Summary

This update refactors '=='/3 to avoid any recursive structural equality checks and instead rely entirely on Prolog’s built-in optimized operators.

The implementation:

  • Uses strict term equality (==/2) as the primary fast path
  • Falls back to arithmetic equality (=:=/2) when both arguments are numbers
  • Introduces no recursive traversal
  • Preserves performance by leveraging built-in predicates only

This approach removes the performance concerns associated with recursive equality checking while maintaining clear and predictable semantics. Since no custom recursion is introduced, the change should not raise the benchmarking issues previously mentioned.

Feedback and suggestions are welcome.

Copy link
Collaborator

@patham9 patham9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not solve the issue, what if it is (1) and (1.0) in a list we are comparing with. Did you forget our discussion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants