Bug 11092 – @commutative annotation for commutative functions

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-22T03:16:00Z
Last change time
2017-06-25T12:26:38Z
Assigned to
nobody
Creator
daniel350

Comments

Comment #0 by daniel350 — 2013-09-22T03:16:01Z
The title should be self-expressive, for heavily constrained functions, it would be nice to just be able to tag them as commutative rather than spam the identical function prototype with a redirect to original.
Comment #1 by bearophile_hugs — 2013-09-22T04:22:47Z
(In reply to comment #0) > The title should be self-expressive, This is an enhancement request, so the title is never self-expressive: - What are some use cases? - What are the limits? - Do you mean just functions with two arguments? - What if one, the other or both arguments have a default value? - What about testing. QuickCheck-like tools for D would enjoy to know what functions are annotated with such @commutative, to test at run-time they are actually commutative. For this std.traits.functionAttributes will need to take into account @commutative functions too. More notes: - std.functional.memoize could detect a @commutative function and sometimes reduce the memory usage of its associative array.
Comment #2 by dlang-bugzilla — 2017-06-25T12:26:38Z
Please see https://github.com/dlang/DIPs#procedure for instructions on how to propose a change in the language. Bugzilla is not the correct avenue for that.