-
Notifications
You must be signed in to change notification settings - Fork 50
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
[WIP] Parser return lifts #548
base: master
Are you sure you want to change the base?
Conversation
9ffd2ef
to
6008785
Compare
List(), | ||
List(EagerPlanter("foo", _, idB1)), | ||
List( | ||
QuotationVase( | ||
Quoted(Infix(List("dyn1 || ", ""), List(ScalarTag(idB1, _)), false, false, QV), List(EagerPlanter("foo", _, idB)), Nil), | ||
Quoted(Infix(List("dyn1 || ", ""), List(ScalarTag(idB, _)), false, false, QV), List(EagerPlanter("foo", _, idB2)), Nil), | ||
idA1 | ||
) | ||
) | ||
) if (idA == idA1 && idB == idB1) => | ||
) if (idA == idA1 && idB == idB1 && idB == idB2) => |
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.
If I understand correctly how q
is evaluated, where q
is
val q = quote {
sql"#$a || ${lift("foo")}".as[String]
}
then
- The "lift" macro fires first which returns
EagerPlanter("foo", ...).unquote
- Quote macro is called which passes
'{EagerPlanter("foo").unquote}
to the parser QuotationParser
fires first onUprootableUnquote
where expr is
EagerPlanter("foo")
and addsEagerPlanter("foo")
toLifts.lifts
InfixParser
then fires, as part of parsingExtractLifts
is called which gets the
"foo" lift.
which, given that we are now "getting" lifts from the parser, makes sense the EagerPlanter("foo")
would be now included in the lifts
of the returned Quoted
.
It's not clear to me, though, if this will yield any difference in behavior. I have a TODO for this.
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.
This logic sounds right. The actual EagerPlanter(foo) is supposed to live inside the QuotationVase. I don’t think the ExtractLifts inside InfixParser is even necessary anymore and you should try to remove it.
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.
I don’t think the ExtractLifts inside InfixParser is even necessary anymore and you should try to remove it.
I'll start looking into this
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.
@deusaquilus Indeed, you are right; simply getting the "lifts" and "pluckableUnquotes" from the Lifts
context after parsing the Param
s seems to work: all of the tests with InfixTest
pass.
Just pushed up a commit with this change.
@@ -370,7 +370,7 @@ class QuotationTest extends Spec with Inside { | |||
qqq must matchPattern { |
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.
TODO @masonedmison I still need to convince myself that this is a sound change
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.
Looks alright to me. We can talk about it when I’m back in a couple days.
fcc793c
to
6abb530
Compare
Problem
As part of discussions with @deusaquilus, he pointed out that "lifts" can be gotten from the parser instead of calling
ExtractLifts
. CallingExtractLifts
ends up being quite an expensive operation.Solution
Within the quote macro, "lifts" are gotten from the parser instead of by executing
ExtractLifts.
Checklist
README.md
if applicable[WIP]
to the pull request title if it's work in progressquill-sql-tests
and compare with a previous runin which lifts are gotten from
ExtractLifts
in the quote macro.*: I believe the existing tests should cover all of the cases to test.
@getquill/maintainers