Closed yurydelendik closed 2 years ago
It would read most naturally if annotations that are on their own line were prefixes, while inline annotations (including those on the end of a line) were suffixes. That's basically how we read comments. It would also introduce significant whitespace, so it will have to be one or the other in practice.
If the annotation was a prefix, there'd be this case, where anchoring to the i64.instruction
would be counter-intuitive, so prefix-based annotations would ideally never appear on the end of a line:
i32.instruction (@a "anchor to the i64.instruction")
i64.instruction
However, in these cases, it looks fine:
(@a "anchor to the i32.instruction") i32.instruction
(@b "anchor to the i64.instruction")
i64.instruction
If annotations were suffixes, this would make perfect sense:
i32.instruction (@a "anchor to the i32.instruction")
i64.instruction
However, the following example would be counter-intuitive (as it anchors to the i32.instruction
still), but avoiding doing this would be less of a loss for readability than not being able to annotate at the end of the line:
i32.instruction
(@a "anchor to the i32.instruction") i64.instruction
This is now a problem though:
i32.instruction
(@a "anchor to the i32.instruction")
i64.instruction
If the way we read comments applies to annotations too, you have to pick between, this:
i32.instruction (@a "anchor to the i64.instruction")
i64.instruction
Or this:
i32.instruction
(@a "anchor to the i32.instruction")
i64.instruction
As far as the Wasm spec itself is concerned, annotations are not "attached" anywhere. This is intentional. It is completely up to a custom interpretation/definition of a specific annotation to define their individual meaning, including the meaning of their placement. We can't predict all possible use cases, so it would be counter-productive to prescribe any form of interpretation, in the same way we don't do that for custom sections in the binary format.
@rossberg - Ah. That makes sense.
We probably need to specify exact location where annotation attached to, e.g. is there a difference between these two constructs:
(local $var1 i32 (@name "i"))
and(local $var1 (@name "i") i32)
. Does the(@name ...)
annotation attached to the(local... )
in both cases?The same applicable to operators in functions and init expressions, e.g.: