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
At my work we use a custom language which does not support captures in lambdas. Instead we have simple definitions of semantic macros.
Reading the counter.rs source therefore had me wonder... how about an alternative API using begin/end calls instead? I assume the main reason for callbacks is safety: not missing a matching end call.
Matching begin/end using Rust macros might provide increased confusion in traces.
If we just don't enforce this at compile time, control flow could become visibly simpler and more open and powerful, not being coupled to function boundaries. This could also open up for more complex composition.
I think it's a tradeoff worth pondering, despite not necessarily being idiomatic Rust. What do you think?
I'm considering e.g. crashing at runtime if a node ends up unclosed, together with some simple API like cx.push(MyContainer::new()); { ... } cx.pop(); or something similar.
Would love to hear your thoughts on this!
The text was updated successfully, but these errors were encountered:
We've gone back and forth on this a bunch. It used to be simple begin/end before f2d8733, which introduced the scoped closures. @maan2003 also explored a guard pattern in #1, but we came to the conclusion its drawbacks outweighed its advantages.
I'm personally reluctant to use macros where plain code can suffice, but this question of avoiding imbalance is a tough one.
It's possible there's a really good solution to this, but we might end up with going with the least bad thing.
Hi Raph! Great work!
At my work we use a custom language which does not support captures in lambdas. Instead we have simple definitions of semantic macros.
Reading the counter.rs source therefore had me wonder... how about an alternative API using begin/end calls instead? I assume the main reason for callbacks is safety: not missing a matching end call.
Matching begin/end using Rust macros might provide increased confusion in traces.
If we just don't enforce this at compile time, control flow could become visibly simpler and more open and powerful, not being coupled to function boundaries. This could also open up for more complex composition.
I think it's a tradeoff worth pondering, despite not necessarily being idiomatic Rust. What do you think?
I'm considering e.g. crashing at runtime if a node ends up unclosed, together with some simple API like
cx.push(MyContainer::new()); { ... } cx.pop();
or something similar.Would love to hear your thoughts on this!
The text was updated successfully, but these errors were encountered: