Replies: 11 comments
-
Use in |
Beta Was this translation helpful? Give feedback.
-
Thank you very much! A pity that |
Beta Was this translation helpful? Give feedback.
-
Generally pinning the task to a single thread is very cumbersome or not possible ( Pinning a normally spawned task to a single thread is not possible because this feature is fundamentally incompatible with the |
Beta Was this translation helpful? Give feedback.
-
For completeness, follow up on this !Send !Sync aspect: https://users.rust-lang.org/t/how-to-deal-with-external-type-which-is-send-and-sync/47530 Is there any plan to have Pairs at least |
Beta Was this translation helpful? Give feedback.
-
How about adding an optional feature to turn all the |
Beta Was this translation helpful? Give feedback.
-
The main issue with such is that it's not really a "strictly additive" feature. Additionally, it's not really possible to be generic between That said, I've primarily been working with Rowan recently, which uses Arc trees rather than Rc, so I do agree that being able to share the parse between threads is useful. (Actually, Rowan uses an Arc for the tree structure itself, but Rc for traversal of the tree, so it's sort of a hybrid approach.) |
Beta Was this translation helpful? Give feedback.
-
That's why I proposed a feature, we could do something like: #[cfg(not(feature = "sync-send"))]
type RefCounted<T> = std::rc::Rc<T>;
#[cfg(feature = "sync-send")]
type RefCounted<T> = std::sync::Arc<T>; and replace every occurence of I wrote a proof of concept here and it seems to be a drop-in replacement. The only issue I found was that in the docs |
Beta Was this translation helpful? Give feedback.
-
The problem is the "purely additive" requirement for features. Sure, a feature flag could add the "feature" of send/sync for the |
Beta Was this translation helpful? Give feedback.
-
I don't follow: if the feature flag is not in default flags, we stay like today, don't we? with @SkiFire13 prototype, we pay for Arc only if we opt-in send-sync feature in our Cargo.toml, or am I missing something? |
Beta Was this translation helpful? Give feedback.
-
Features are unified accross the entire dependency tree. Let's say you use both tera and nalgebra, both of which use pest. Now you use pest directly, and enable the pairs-are-sync feature. Tera and nalgebra also use pest, and there's a single version of pest compiled into your binary. Both tera and nalgebra will be slower to manipulate pairs, as they are using atomic operations, even though both of those libraries didn't enable the feature and are developed to not need it. If anyone in the dependency tree activates a feature, it's enabled for everyone. This is even more insidious if, say, a test dependency is the only one that enables the feature, as now you're paying for it without even benefiting from it anywhere. It's the same reason you shouldn't use mutually exclusive cargo features; features are intended to be strictly additive, because once they're on they're on for everyone. |
Beta Was this translation helpful? Give feedback.
-
Oh I understand better now! What about another module
|
Beta Was this translation helpful? Give feedback.
-
I'd like to store the
Pairs<>
in order to avoid reparsing of the same expression and cloning it before reevaluate it usingPrecClimber
.I have two concerns with that:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions