I found that when I need structural types, it is almost always because the library I wanted to use was not designed properly (for example, the absence of superclasses in cases like StringBuilder / StringBuffer).
Therefore, if you want to use structural types for other reasons, this could be a design issue that would be more serious than configuration or performance considerations. A Scala type system is powerful, and using structural types is a bit like a “failure” to get the right “normal” facility. Therefore, if you have code that seems to “require” structural types, try to analyze why this is so, and perhaps ask the community if it can be improved ( https://codereview.stackexchange.com/ seems good place for this) if you are stuck.
By the way, everyone is inclined to overuse the function that he just “crashed”, for example. newbies coincide like crazy as soon as they get the concept, even if there are better ways (for example, in the case of Option functions like map, flatMap, foreach ...).
Landei
source share