- 
  Notifications
 You must be signed in to change notification settings 
- Fork 1.1k
plus–minus ± scala.compiletime.ops? #17491
 
 
 3xau1o
 
 
 
 started this conversation in
 General Discussion
 
 -
The following type operation is valid
import scala.compiletime.ops.int.+ val a: 2 + 2 = 4
Is also valid to have union type operations
import scala.compiletime.ops.int.- val b: (2 + 2) | (2 - 2) = 4
Can it be less verbose with a± math operator?
var c: 2 +- 2 = 4 // ok c = 0 // ok
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
It may be a better idea to introduce a type like this in your codebase:
type +-[A <: Int, B <: Int] = A + B | A - B
The cost of introducing new types like this in stdlib is possible confusion and growing complexity. Other types in compiletime.ops are impossible to implement using just type defs, this one is.
Beta Was this translation helpful? Give feedback.
All reactions
 
 0 replies
 
 
 
 
 Sign up for free
 to join this conversation on GitHub.
 Already have an account?
 Sign in to comment