Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

plus–minus ± scala.compiletime.ops? #17491

3xau1o started this conversation in General Discussion
Discussion options

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
You must be logged in to vote

Replies: 1 comment

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /