tarsa
October 9, 2019, 7:36pm
109
AMatveev:
Nevertheless it is not the most comfortable thing to write
import some.word.that.i.always.forget._
The receiver function can help in such situation.
Of course the good programmer know by heart all that he needs. But I it is annoying situation for me.
When I see value.method(arguments)
I expect that either method
is defined on type of value
or there is implicit conversion in scope that provides that method. It doesn’t seem helpful to add receiver methods to that list. I would need to search in three kinds of places instead of two.
Also, Rust compiler has no problems suggesting that you forgot to add:
import some.word.that.i.always.forget._
to enable certain extension methods. Look here:
In my opinion, changing keywords from implicit to given/ implied/ whatever is just another minor tweak when it comes to beginner friendliness, albeit bringing heavy migration pain.
First I’ll link to my previous post on this subject:
Typical problem with implicits is that implicit conversion doesn’t work. Changing syntax for implicits has zero influence on that. A pretty rare and simple to fix problem is when we have to disambiguate between implicit and explicit parameter lists with expli…
I’m talking more about availability of extension methods rather than typeclass instances per se. In Rust, typeclass instance is not available as a value (even trait objects used for having virtual methods are bound to specific struct or enum instances) but instead visibility of a typeclass adds extension methods to a type.
Example code in Rust https://www.ideone.com/SXefDQ
use struct_here::MyStruct;
//use trait_here::MyTrait; // rustc suggest that, IntelliJ inserts automatically
mod struct_h…
Note that Rust has keyword use
instead of import
.
1 Like