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

Stefan Plantikow stefan.plantikow at googlemail.com
Wed Jan 25 14:10:19 PST 2012


Hi,

Am Mittwoch, 25. Januar 2012 um 21:12 schrieb Patrick Walton:

> 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.
> 
Hmm, maybe the compiler could help with that by having a simple macro which would print the list, or by having some flag which would emit it.
> 
> (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...)
> 

I kind-of like it that way because it simplifies replacing record access with getter typeclass methods without too much refactoring.

> (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.
> 
Maybe there is the need for an "import impl module::*" to get them all.
And an "import all module::*". I would find it a tad annoying to need 2 import statements to import everything from a single module.
> 
> (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 '::'.
> 
That may just be me but I always found that ugly and slow to type (on non-us keyboards at least)




Stefan Plantikow
 



More information about the Rust-dev mailing list