Further simplify the attribute-based macros for executable code #1843
ziqiaozhou
started this conversation in
Language design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As I mentioned in #1716, I added the attribute-based macro for executable function to make it easier to integrate verus annotations in executable code. But not all cases can be easily achieved by attributes, especially when I need annotation inside function body.
Passing ghost variables to functions
Thus, I have added a placeholder macro, proof_with!(), which injects proof code that is later parsed by the verus_spec macro along with the statement that follows it.
But the current version still requires some changes to existing code in order to insert ghost variable into executable properly.
For example, proof_with does not yet support nested pattern.
If we have some nested function calls that needs to take ghost variables. We need to change
to
A potential solution is to let proof_with to capture a pattern and then fill the ghost to statement following it. For example,
I think it should look simplier in practice since we may only need to pass a few ghost var to some functions not all of them.
Annotating closure
In addition, annotating a closure is also a pain. For example,
should be rewritten to
#1759 might be helpful to avoid annotations. But when it is needed, we still need to change existing line. I am not sure whether it makes sense to define a proof_with-like faked macro to annotate a closure expr following the macro.
And again, we may also need a pattern if the statement contains more than one closure.
Annotating a loop
Currently, annotating a loop is simple. But we may still see some limitation on using unstable feature #![feature(proc_macro_hygiene)].
To unify the use of annotations inside executable, I may also need a proof_loop!() and rely on the function-level's verus_spec to rewrite statements that follows proof_xxx!().
Your feedback is more than welcome!
Beta Was this translation helpful? Give feedback.
All reactions