D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17573 - Make opCmp more flexible
Summary: Make opCmp more flexible
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-29 19:24 UTC by Anders Halager
Modified: 2024-12-13 18:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Anders Halager 2017-06-29 19:24:53 UTC
The way custom comparisons are currently implemented force you to always return an integer and doesn't tell you what operation you are doing.

An example of how it can bite is that mir can't do elementwise comparisons similar to how it does addition or multiplication since it has to return an int for comparisons.
So a + a == [2, 2, 2] and a * a == [1, 1, 1] but you can't express a < a == [false, false, false].


I get the logic of only making the user create a single comparison function but maybe a possible fix would be to check if there is an opBinary for the relevant comparison operator before doing the usual opCmp logic.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:52:55 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19270

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB