-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Typeclass/interface implementation #1227
Comments
Oops, tagged the wrong Marijn. Now tagging @marijnh. |
I like the direction this is taking, especially the unification of static type classes and the proposal for boxed existentials (interface, value). Have added an idea on how to add delegation to the wiki. |
No conflict resolution or polymorphism yet. Issue #1227
Get rid of expr_self_call, introduces def_self. `self` is now, syntactically, simply a variable. A method implicitly brings a `self` binding into scope. Issue #1227
Something will still have to be done to the AST to make it possible to say `x.foo::<int>()`, since currently field access never allows type parameters. Issue #1227
(No one is actually reading it yet.) Issue #1227
And fix a bug where importing anything from an external module would import all impls in the module. Issue #1227
We should probalby warn when defining a method foo on {foo: int} etc. This should reduce the amount of useless typevars that are allocated. Issue #1227
This way, you can explicitly provide type parameters when calling a generic method. Issue #1227
The parameters of the impl weren't being combined in the right way with the parameters of the methods. The test worked only by accident. Issue #1227
Extern interfaces still don't get recognized. Issue #1227
I am not sure, does the current approach/plan include default implementations?
could implement a function |
Not in the first iteration. They're probably useful enough to be included at some later point. |
Reached a point where simple uses of interfaces without bounds work. Issue #1227
The trick of interpreting parameters to the iface type as parameters to the impl was just too magical. Issue #1227
New demo of what's possible: https://github.com/graydon/rust/blob/master/src/test/run-pass/iface-to-str.rs |
Very nice. |
I wonder whether we should drop "of":
vs
The latter contains less words and characters to mentally process, but has no diminished clearness to me. |
We can't drop |
Aligning the type parameters of the ifaces, impls, and methods correctly in typeck is almost brain surgery. Seems to work now for everything I threw at it, but might still break in other corner cases. Issue #1227
I.e. fn foo<T: seq<T>>(...). This leads to weird circularities that seem to never make any sense, so it seems prudent to forbid it. Issue #1227
Also, move checking of ifaces into the collect phase of typeck to give further passes some guarantees. Issue #1227
Have you found that naming implementations is strictly necessary? |
Only enable JIT tests on x86_64
* Improve mem::swap test to cover more types * Remove the mem::swap() hook
This is a stub bug, tracking @marijnh's efforts in implementing typeclasses. Created so that I could link to it from another bug.
More detail: https://mail.mozilla.org/pipermail/rust-dev/2011-November/001010.html
The text was updated successfully, but these errors were encountered: