Closed micahkendall closed 4 months ago
Hey, thanks for the PR, that's an interesting idea to be discussed.
The current implementation path however duplicates a lot of logic at every level of the compiler and doesn't introduce any clear semantic change.
It seems that what is needed here is merely a way to keep some specific traces in the compiler. We likely don't need a new tracing mechanism for that but rather a way to distinguish them from other. In particular, the code generation bits do not and should not care about this distinction. So the addition shouldn't leak out of the AST. Note that I am not advocating against a new syntax, that probably makes sense. But it shouldn't bubble all the way down to the code generation.
An example of this lies in the property test framework labelling feature; we use a NUL byte as prefix to distinguish labels from other traces. We could use a similar mechanism with a special unicode character to identify events.
@micahkendall this is good enough for us to merge and clean anything up ourselves. Thank you for the idea.
I'll get together with @MicroProofs and sort through anything that's awkward and I'll also add some unit tests etc.
This adds the emit keyword (emissions) which is a kind of trace that is used for effectful offchain functionality and therefore should never be erased (even when Silent option to the keep traces flag is passed).
This is largely a UX feature to make it easier to implement the following pattern: https://x.com/SebastienGllmt/status/1774479357370945544?s=20