|
|
|
|
|
by saghm
1643 days ago
|
|
I might just not be understanding what's special about this keyword, but my instinct when I see this sort of thing is to wonder if a proc macro could get us most of the way there. Obviously that isn't possible in some cases, and extra syntax is needed (e.g. the `await` keyword), but this at least feels like something that syntax-wise would probably fit pretty well as an annotation on a function, e.g. #[context = "foo"]
fn bar() {
foo.something
}
If a proc macro couldn't provide this functionality, I still think I'd prefer it being some sort of top-level attribute rather than a keyword, mostly due to the fact that it's visible without having to look into the function, which makes it easier to notice due to visual scanning or when using code folding to hide the bodies of methods by default. Obviously this is mostly a personal preference, but I have a pretty strongly but somewhat vague sentiment that all the info needed to understand the scope of a function should appear in the signature (or right above, in the case of annotations) rather than inside. |
|