-
Notifications
You must be signed in to change notification settings - Fork 101
Align FluentBundle with the new JS FluentBundle API #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The initial performance is worrying.
I haven't investigate the source of the regression yet. My initial guess is that creating two hashmaps (one to return from |
Yep! Updating the benchmark to not use the
That likely means that hashmap allocation is costly, but that also allows users not to allocate if they don't need to. |
I think I found a problem that may be hard to overcome. In the current design, Since all WebIDL types have to be But, in the new design, I need to either expose an In both cases, I need to hold a reference to a field inside the
I don't see an easy way to get there, unless I change the AST to store every pattern as an |
Hmm, one option that miight work is that I could try to make the Pattern be a micro-resource, with its own Quite frankly, I don't find either approach really appealing especially since its not supposed to be an edge case, but the core of how we want to handle message formatting. |
Now that entries are stored in bundles as indices, does the lifetime of Re. hashmap instantiation: In #120, it looks like a new Alternatively, would it make more sense to return a vector of attributes rather than a hashmap? This would be a divergence from the JS API, but perhaps well justified? |
Re.
Can we only |
Just this.
I don't think we can do that lazily.
Sure, it's just that such AST will look quirky. I'm trying to decide if this issue is a signal that the API design is flawed. |
I see this as a way to encode in the AST the fact that we want to be able to lend out these patterns to the calling code. |
Which is not what AST is about. It leaks the runtime API expectations onto a view of the source. :( Having to RC Patterns in source so that we can expose them in public via WebIDL seems weird. I'm trying to think of other ways to achieve that - where the public "Pattern" would hold a weak reference to the bundle and become unusable if the What's your expectation for JS? If I delete the bundle, and the res, should the |
But we already do it by using the AST as the data storage for messages in bundles, and by making the resolver work with it, too. An alternative would be to create separate data structures in |
Currently, this is an implementation detail. We can switch it anyway we like without changes to the public API. When I say public I mean - from the perspective of So, when someone is working with
I may try that instead. |
My expectation is that that is allowed to throw. Evaluating a message against a different bundle isn't cool. Which sounds like a bug, but I view it as a compromise between messages being abstract around their values and attributes, and being able to inspect messages w/out evaluating them, while having a small API surface. |
So, I'm not sure if I agree tbh. I can see this being a perfectly sane way to use Fluent:
I see. I'm wondering if there's a better way to handle that. |
There's another benefit of the switch to In #94 we discussed the possibility of having an API that takes a I'm not sure how can we get the Rc'ed Pattern into this picture. One idea would be to do:
and return it in This feels weird, but will be fast and light. |
This has landed in 2a4b92f |
This is basically porting projectfluent/fluent.js#380 to fluent-bundle-rs.
The text was updated successfully, but these errors were encountered: