-
Notifications
You must be signed in to change notification settings - Fork 55
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
Support inline expressions in validators #6
Comments
The transformation macro currently assumes that every expression in the validation block is a validation rule (i.e. typechecks to Validator[_]), and needs to be rewritten to be able to reorder such a block to a (list of statements; list of validators) tuple. Seems like a worthwhile endeavor, adding to 0.3 milestone roadmap. |
I've written a proof-of-concept implementation on a separate branch, you can see the relevant tests here (the bottom It's currently severely limited in that it assumes ordering and doesn't do escape analysis; in simple terms, each validator "tacks on" the preceding code lines. This means something like I need to do some further research into the macro context/compiler architecture to see if it's feasible to do some sort of escape analysis to figure out which snippets of code are necessary for each validator; it's possible that the Async extensions for Scala have already solved this. |
Nice! |
The necessary mechanism for rewriting the code ended up being quite complex (equal to, or possibly rivalling, the complexity of the async/await code transformation). I wonder if there's enough interest in this feature to warrant the time? |
Obviously this is a simple irrelevant example but it doesn't compile.
The text was updated successfully, but these errors were encountered: