-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Some useful tree constructors #5567
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
Comments
Those should not be implemented in the core. They should be implemented in some library. The let abstraction is already in https://github.com/nicolasstucki/quoted-util |
Why ? |
@nicolasstucki Just checked https://github.com/nicolasstucki/quoted-util, it seems they are not tasty reflect util, but |
Oh, yes. Those are not on trees. Though they are safer. |
The provided constructors are not enough:
We cannot use quote to introduce the binding, because we do not know the type of case Term.Apply(sel @ Term.Select(lhs, op), rhs :: Nil) =>
case ">" =>
val Term.IsSelect(select) = sel
def app(l: Expr[Any], r: Expr[Any]): Expr[Boolean] =
Term.Apply(Term.Select.copy(select)(l.unseal, ">"), r.unseal :: Nil).seal[Boolean]
val left = lhs.seal[???]
val right = rhs.seal[???]
'{
val _left = ~left
val _right = ~right
val _result = ~app('_left, '_right)
Bool.binaryMacroBool(_left, ~op.toExpr, _right, _result, ~prettifier)
} It will be really nice to have something like |
#5651 shows how to implement |
I think core and non-core are just a problem of separation, there are multiple ways to achieve the separation, e.g. different packages, not neccesarily in different libraries. |
Uh oh!
There was an error while loading. Please reload this page.
In implementing ScalaTest macros, I find two tree constructors are useful:
The constructor
selectApply
should do overloading resolution internally, but no other adapation (like insertingapply
nor implicits). The constructorlet
allows creating bindings friendly.The current implementation of
assert
is as follows:With the two constructors, the implementation can be made more generic & simpler:
The text was updated successfully, but these errors were encountered: