[rust-dev] A couple of tweaks to make typeclasses easier?

Marijn Haverbeke marijnh at gmail.com
Wed Jan 25 12:21:48 PST 2012


> (1) Typeclass imports become "import impl". So you'd write "import impl
> driver::diagnostic::handler" where you'd write "import
> driver::diagnostic::handler" today. This way, when you look at a method call
> and you don't know where it's coming from, you just grep for "import impl"
> and look at all the implementations in scope.

It can often be pleasant to have impls included in a * import (but
then, it is also occasionally not what you want). Similarly, it is
currently very convenient to name a type and an impl with the same
name, so that importing it gets you both the type and its methods.
Maybe we can somehow tweak the syntax to also allow a form that
imports both impls and other things?

> (2) Change method calls to '->', like C++, Perl, and PHP. That operator is
> free and it has precedent. And getting away from overloading the dot worked
> well when we changed module access from '.' to '::'.

I considered this when I did the first implementation. I figured that
simply giving record field access precedence was good enough, but the
readability argument is valid.


More information about the Rust-dev mailing list