Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The language, in general, wants you to be explicit about what you're working with. So implicit access to interface members isn't a thing, you need to say that "x is this interface type" or cast.

In F# 6 things are changing a bit, and may possibly change in the future. There are various classes of cases where the type information is known, but the compiler still required you to explicitly cast things to be happy. That's no longer case. This link[0] has 3 examples that don't compile with F# 5 but will compile with F# 6.

[0] https://sharplab.io/#v2:DYLgZgzgNALiBOBXAdgHwPToAQFMAeAhgLYA...



> implicit access to interface members isn't a thing, you need to say that "x is this interface type" or cast.

If the compiler already knows that it implements interface X Y and Z, it seems unnecessary to require it (unless those interfaces have conflicting names, in which case you would have to be explicit due to ambiguity).

I feel like many languages are walking away from being so explicit, in particular I've noticed C# becoming more implicit over the years.


Implicit upcast? That's amazing, I feel like that's going to help a lot with many branched functions.


Yeah, it's a good feature. It's been done carefully -- there's room to do more of this kind of upcast conversion in the future -- but there's also a danger of creating code that behaves weirdly, too. See here for some of the dangers in Scala 2: https://latkin.org/blog/2017/05/02/when-the-scala-compiler-d...


It's worth mentioning that 4 out of 5 puzzlers in this article are fixed in Scala 3. The one that remains behaves arguably as it should.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: