You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes the attribute logic brittle and more difficult to extend than it needs to be. Specifically, the trace name is a positional argument which is both required and optional:
from the attribute logic PoV it is required
from the user PoV it is optional
Other arguments can be prohibited or required from the attribute logic PoV, e.g. enter_on_poll is prohibited for non-async functions, but required for async functions.
We can't do anything about the required/prohibited/optional properties - these arise naturally from the domain.
We can simplify required/prohibited/optional parsing logic by not complicating things with positional and named/keyword parameter categories.
That is, by removing the use of a positional arguments.
Specifically, in the course of issue #113, landing as PR #127, the following supported syntax has simplified matters by eliminating the need for a validation stage, leaving only a parse stage:
#[trace] fn f(){} shorthand for #[trace(name='f')] fn f(){}
#[trace(enter_on_poll=true)] async fn f(){} shorthand for #[trace(enter_on_poll=true,name='f')] async fn f(){} . Note: Here order is immaterial.
#[trace(name='a')] fn f(){}
The existing mixture of named and positional arguments would no longer be accepted:
#[trace] fn f(){} shorthand for #[trace('f')] fn f(){}
#[trace(enter_on_poll=true)] async fn f(){} shorthand for #[trace(f,enter_on_poll=true)] async fn f(){} . Note: Here order is material.
#[trace('a')] fn f(){}
This would improve the readability of code.
This would deviate from the tracing crate convention, depending on your PoV this is a positive or negative.
Once there is a comprehensive test suite in place and all bugs are eliminated - perhaps then we could consider adding subtle corner cases to the parsing logic by supporting a mixture of positional and named/keyword arguments?
Thoughts?
The text was updated successfully, but these errors were encountered:
taqtiqa-mark
changed the title
Feature: All trace attribute arguments are named arguments
Feature: All trace attribute arguments are named/keyword arguments
Apr 27, 2022
Uh oh!
There was an error while loading. Please reload this page.
Currently the
#[trace]
attribute is a mixture of:This makes the attribute logic brittle and more difficult to extend than it needs to be. Specifically, the trace name is a positional argument which is both required and optional:
Other arguments can be prohibited or required from the attribute logic PoV, e.g.
enter_on_poll
is prohibited for non-async
functions, but required forasync
functions.We can't do anything about the required/prohibited/optional properties - these arise naturally from the domain.
We can simplify required/prohibited/optional parsing logic by not complicating things with positional and named/keyword parameter categories.
That is, by removing the use of a positional arguments.
Specifically, in the course of issue #113, landing as PR #127, the following supported syntax has simplified matters by eliminating the need for a validation stage, leaving only a parse stage:
#[trace] fn f(){}
shorthand for#[trace(name='f')] fn f(){}
#[trace(enter_on_poll=true)] async fn f(){}
shorthand for#[trace(enter_on_poll=true,name='f')] async fn f(){}
. Note: Here order is immaterial.#[trace(name='a')] fn f(){}
The existing mixture of named and positional arguments would no longer be accepted:
#[trace] fn f(){}
shorthand for#[trace('f')] fn f(){}
#[trace(enter_on_poll=true)] async fn f(){}
shorthand for#[trace(
f,enter_on_poll=true)] async fn f(){}
. Note: Here order is material.#[trace('a')] fn f(){}
This would improve the readability of code.
This would deviate from the
tracing
crate convention, depending on your PoV this is a positive or negative.Once there is a comprehensive test suite in place and all bugs are eliminated - perhaps then we could consider adding subtle corner cases to the parsing logic by supporting a mixture of positional and named/keyword arguments?
Thoughts?
The text was updated successfully, but these errors were encountered: