On Wednesday, 5 September 2018 at 01:06:47 UTC, Paul Backus wrote:
On Tuesday, 4 September 2018 at 16:36:20 UTC, Nick Treleaven wrote:
My syntax for parameters that may get aliased to another parameter is to write the parameter number that may escape it in its scope attribute:

On Sunday, 2 September 2018 at 05:14:58 UTC, Chris M. wrote:
void betty(ref scope int*'a r, scope int*'a p) // okay it's not pretty

void betty(ref scope int* r, scope(1) int* p);

p is documented as (possibly) escaped in parameter 1.

Would using parameter names instead of numbers work? As an unfamiliar reader, it wouldn't be clear at all to me what `scope(1)` meant, but `scope(r) int* p` would at least suggest that there's some connection between `p` and `r`.

It's indeed imho better as numbered parameters are a pita. Any change is annoying and fragile. I cannot count how often in C I had issues with annotations like __attribute__((nonnnul(5,9))) and __attribute__((format(printf, 3, 4))) when I had to change the parameters.

Reply via email to