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
Iterators currently suffer from complete type erasure. That is, every iterator is the same iterator type. There's also a lot of awkward plumbing it would be nice to get rid of which would allow iterators to be less special.
Current iterators are implemented by always wrapping them into one dynamic Iterator. Instead, iterators should be implemented by dynamic values implementing protocols. The Iterator type only needs to represent a dynamic iterator.
The first challenge is that we don't have "protocol hierarchies".
In Rust, an iterator implementation has to implement next, but all the other methods are optional. Rune doesn't support overriding optional methods like this, since it would require looking up two methods in order:
The implemented method.
If the method isn't implemented, fallback to the default implementation.
Hopefully this can be resolved efficiently when the RuntimeContext is constructed. Since each method must be an Arc, it should be simple enough to clone them so all possible methods can be filled out.
It would also be beneficial to introduce traits. Particularly when checking if a type implements a given trait or not.
A trait would simply be a collection of protocols, and a unique hash combination stored in a set to allow for testing whether a type implements a trait or not. The larger part would be implementing the necessary compiler and context infrastructure to define and implement traits.
The text was updated successfully, but these errors were encountered:
Iterators currently suffer from complete type erasure. That is, every iterator is the same iterator type. There's also a lot of awkward plumbing it would be nice to get rid of which would allow iterators to be less special.
Current iterators are implemented by always wrapping them into one dynamic
Iterator
. Instead, iterators should be implemented by dynamic values implementing protocols. TheIterator
type only needs to represent a dynamic iterator.The first challenge is that we don't have "protocol hierarchies".
In Rust, an iterator implementation has to implement
next
, but all the other methods are optional. Rune doesn't support overriding optional methods like this, since it would require looking up two methods in order:Hopefully this can be resolved efficiently when the
RuntimeContext
is constructed. Since each method must be anArc
, it should be simple enough to clone them so all possible methods can be filled out.It would also be beneficial to introduce traits. Particularly when checking if a type implements a given trait or not.
A trait would simply be a collection of protocols, and a unique hash combination stored in a set to allow for testing whether a type implements a trait or not. The larger part would be implementing the necessary compiler and context infrastructure to define and implement traits.
The text was updated successfully, but these errors were encountered: