3 ms·
I've always thought it would be cool to have a language where functions were tagged as distributive, associative, symmetric/commutative, and monotonic and the o
by User23 8y ago
I've always thought it would be cool to have a language where functions were tagged as distributive, associative, symmetric/commutative, and monotonic and the optimizer (and editor!) used these properties to determine optimizations or simplifications. Note that this would be for all expressions, not just arithmetical ones.
I vaguely recall hearing about some fancy C++ template based techniques for accomplishing this, actually, but haven't looked into it.
- saagarjha 8y agoSwift has operator precedence levels, and you are free to use them for your own operators: https://developer.apple.com/documentation/swift/swift_standard_library/operator_declarations https://developer.apple.com/documentation/swift/swift_standa...
- sbmassey 8y agoMathematica/the Wolfram language does that. e.g the Flat attribute denotes associativity, etc. https://reference.wolfram.com/language/ref/Flat.html https://reference.wolfram.com/language/ref/Flat.html