Replies: 8 comments 13 replies
-
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). |
Beta Was this translation helpful? Give feedback.
-
Adding a |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
I have started a WIP PR #64. Do you think this is the right direction? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
@llogiq I hope you don't mind but I figured the topic was worth moving over to a discussion while we continue to discuss the design of a solution. I'm curious to hear about the project that you're integrating Koto into? Is there anything you can share about it? |
Beta Was this translation helpful? Give feedback.
-
I think I'm getting towards a design that I'm happy with:
The main advantage of this approach is that external values would then also be able to define meta behaviour like overloaded operators. To extend the idea:
@llogiq How does this sound to you? |
Beta Was this translation helpful? Give feedback.
-
@llogiq I finally managed to get to implementing a new |
Beta Was this translation helpful? Give feedback.
-
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.Beta Was this translation helpful? Give feedback.
All reactions