-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove quoted.Const.unapply #10516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove quoted.Const.unapply #10516
Conversation
bd6bc5d
to
b8c8a0b
Compare
b8c8a0b
to
5de3247
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about keep both?
In meta-programming, Const
is more familiar to users and will be frequently used.
There is some redundancy that should be avoided. This extractor can easily be added in a separate library or in a future version of the library. There are two kinds of uses that seem to repeat:
We also want to avoid conceptual confusions between |
The redundancy is indeed a concern. Looking at the changes in tests, it seems to me Maybe we teach users to use |
Yes, we need to teach users to use We cannot keep |
If 99.99% usage of |
We cannot use |
Short story, |
Where did you get the 99.99%? I don't see any legitimate use of |
And most uses of expr match {
case '{ StringContext(${Varargs(Consts(parts))}: _*) } => but this value can be unlifted directly val parts = expr.unliftOrError.parts |
I just want to use the conditional to emphasize there could be a valid argument for a different design other than the argument of expressiveness. However, just did a quick search under For |
Which one would be better with |
I propose to use |
That is exactly what I want, but the following statement seemed to indicate that there where some that should be kept as
Did I misunderstand? |
I should remove |
So we agree that in general the extractors should be avoided? Uses of |
Good. That is exactly what happened to the code in the community build. |
I updated the first comment to reflect the point that it is better to not use extractors. |
Yes, the changes in the CB look good. It's good to use |
I would not leave I would rather add it to the old |
|
@nicolasstucki IIRC, there are two issues with replacing
|
This PR takes care of the semantics. We could try to rework the name if we find a better one in a following PR. |
Could you be more specific about this? It seems to me that if |
|
I checked the documentation of /** A type class for types that can be turned from a `quoted.Expr[T]` to a `T` */
trait Unliftable[T] { ... } From the documentaion above, we can see that |
The documentation of both should match. They were just written at different times and were never synced.
|
The subtle issue here is that a literal reading of In contrast, a literal reading of |
It seems to me, a valid argument to remove By removing The argument above depends on whether all usage of |
Non of the extractors allow evaluation in the general sense. They only perform a minimal evaluation that take direct value construction into values, such as evaluate |
5de3247
to
c307589
Compare
4286efd
to
e03231f
Compare
e03231f
to
e2d1090
Compare
This extractor was replaced with the more versatile extractor `quoted.Expr.unapply`. Usually, it is better to use `expr.value`/`expr.valueOrError` when it is simpler to do so. * Remove definition of `quoted.Const.unapply` * Replace uses of `Const` with `Expr` **Migration** * Consider using `expr.value` and them match on `Option` * Consider using `expr.valueOrError` * Replace `Const(x)` with `Expr(x)` if the type is known * Replace `Const(x: Int)` with `'{ ${Expr(x)}: Int }` if type of expression must be checked at runtime
e2d1090
to
af72d93
Compare
This extractor was replaced with the more versatile extractor
quoted.Expr.unapply
.Usually, it is better to use
expr.unlift
/expr.unliftOrError
when it is simpler to do so.quoted.Const.unapply
Const
withExpr
Migration
expr.unlift
and them match onOption
expr.unliftOrError
Const(x)
withExpr(x)
if the type is knownConst(x: Int)
with'{ ${Expr(x)}: Int }
if type of expression must be checked at runtime