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

Patrick Walton pwalton at mozilla.com
Wed Jan 25 12:12:07 PST 2012


I've noticed a couple of usability issues with typeclasses:

(1) There's no easy place to search in a file to find all the typeclass 
implementations presently in scope.

(2) It's hard to see at a glance whether a dereference with '.' is a 
method call or whether it's a record field access. It's subtle when a 
record contains closures. (In fact, it can even be ambiguous in such 
cases...)

As a couple of simple-to-implement tweaks, I'd like to suggest the 
following solutions:

(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?

Patrick


More information about the Rust-dev mailing list