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

Graydon Hoare graydon at mozilla.com
Thu Jan 26 17:38:28 PST 2012


On 1/25/2012 12:12 PM, Patrick Walton wrote:

> (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.
>
> (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 '::'.
>
> Thoughts?

A bit opposed to both, sadly. I quite like picking up impls "by 
accident" via "import foo::*", and dislike the aesthetic of ->.

Is the ambiguity between field-access and method-call really biting in 
actual cases? Users really seem to adore '.' as a sub-component 
accessor. We even have people wanting us to go back to '.' for 
module-separator :)

-Graydon


More information about the Rust-dev mailing list