You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/metaprogramming/macros.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -614,4 +614,81 @@ compilation of the suspended files using the output of the previous (partial) co
614
614
In case all files are suspended due to cyclic dependencies the compilation will fail with an error.
615
615
616
616
617
+
### Pattern matching on quoted expressions
618
+
619
+
It is possible to deconstruct or extract values out of `Expr` using pattern matching.
620
+
621
+
#### scala.quoted.matching
622
+
623
+
In `scala.quoted.matching` contains object that can help extract values from `Expr`.
624
+
625
+
*`scala.quoted.matching.Const`: matches an expression a literal value and returns the value.
626
+
*`scala.quoted.matching.ExprSeq`: matches an explicit sequence of expresions and returns them. These sequences are useful to get individual `Expr[T]` out of a varargs expression of type `Expr[Seq[T]]`.
627
+
*`scala.quoted.matching.ConstSeq`: matches an explicit sequence of literal values and returns them.
628
+
629
+
These could be used in the following way to optimize any call to `sum` that has statically known values.
0 commit comments