For syntax, we should first consider how we want it rendered in documentation, then how we want to read the function declaration in syntax, and only then how we would want to write it in syntax.
For documentation, I increasingly feel that the decoupled form would be best, either as arrows, a separate box, or at least a separate line.
We could have interspersed syntax and the renderer could extract that info into a separate line. However, this rendering preference hints that we may prefer to similarly read declarations in syntax on a separate line.
As for writing the declaration, it took me an embarrassingly long time to realize that interspersed dependsOn(x)
was a type annotation. The rules for where to put self
's lifetime in the interspersed form will take a while to internalize. Finally, I am very hesitant to add more parenthesis interspersed with function declarations, as we already have tuples and closure syntax.
We use the argument name instead of the label:
@lifetimes(self: x, y: z, returnValue: z)
func foo(from x: X, to y: Y, using z: Z) -> Z
This is consistent with how the argument name, not the label, is used in the body of the function as well as in the documentation for that function.
The only time that I'd prefer to write an interspersed lifetime annotation would be when there's only one lifetime to specify, and hopefully the inference rules would make this exceedingly rare. The documentation could explicitly render the implicit lifetime dependence.