-
Notifications
You must be signed in to change notification settings - Fork 27
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Easier embedding of Rust / into Rust #63
Comments
Hi @llogiq, glad to hear that you're trying out Koto! I'm sorry that the docs are missing here, I started a documentation effort on the I agree that making custom types is a bit cumbersome at the moment, especially without a guide.. My thinking is that I'd like to make sure the fundamentals are correct and the implementation straight-forward, and then some more ergonomic helpers can be added to make usage a bit friendlier. I'll try to clarify the current approach:
If I understand you correctly you'd rather expect that the If I've got that right I think I would rather extend the type via an embedded Does that make sense? I can see some value in inverting the approach here, it might make the expected usage more explicit (although maybe utilities and docs will help there). |
Adding a |
Yes I can see an advantage there, it'd be cheaper to clone the interface map than having to rebuild it for each new value. |
I have started a WIP PR #64. Do you think this is the right direction? |
Yes I think this is roughly how I would expect it to look, I appreciate you diving in! I'm still unsure if I want to proceed in this direction though. The main concern I have is that this will introduce a new object-like-thing to Koto, and I’d like to avoid that if possible. I'm thinking about an alternative solution which would be to extend
/// The Map value type used in Koto
#[derive(Clone, Debug, Default)]
pub struct ValueMap {
data: Arc<RwLock<ValueMapContents>>,
immutable_data: Option<Arc<RwLock<ValueHashMap>>>,
external_data: Option<Arc<RwLock<dyn ExternalValue>>>,
}; …and Something I like about this is that modules like could expose their features as immutable. It’s never really felt right that there’s nothing to stop a user from saying …and I haven’t figured out a few details of the expected behaviour of map operations over a mix of mutable and immutable entries (like how map operations should apply), but I’d need to start playing with some examples to get a feel for the right direction. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi there. I'm experimenting with embedding koto in another crate, and I feel the protocol around ExternalVaues (as showcased in the example; to my knowledge there are no other docs) is quite cumbersome.
I have built a procedural macro that can insert Rust functions into a given prelude, however, I'd like to also extend it to derive support for my own types (perhaps in conjunction with the proc macro also setting up a kind of vtable). What do you think about simplifying this interface to an
ExternalValue
+ aBox<dyn fn(KeyValue) -> ExternalFunction>
that will do the vtable dispatch? This might both be faster and easier to code against.The text was updated successfully, but these errors were encountered: