Re: Seq :+ repeat parameter
Naftoli Gugenheim <[email protected]> Thu, 07 Apr 2016 23:51:14 +0000
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CANpg8PC1rz1gWo0hm1RhB7+RLN95fqJ=aX1o6k4TD5d2TSbRog@mail.gmail.com> |
On Thu, Apr 7, 2016, 6:44 PM Rich Oliver <[email protected]> wrote: > On Thursday, 7 April 2016 21:56:05 UTC+1, nafg wrote: >> >> >> What is insane or hyperactive about this, and what does it have to do >> with type inference? You wrote the append operator and a tuple, dunno why >> you didn't see that, but no need to blame Scala. >> >> Why not use the ++ operator? >> >> I was aware that I could use ++ "Seq" ........ but I thought there was > repeat parameter operator, allowing me to save the "Seq" characters, so I > tried it. The inferred type was: > > Seq[Product with Serializable with Object {..}] > > I am quite happy to admit to many non trivial flaws as a developer, but I > would ask when the above type or similar is inferred, what percentage of > the time is their an error as opposed to the compiler inferring the > programmers intention? Maybe my knowledge is incomplete but how often do > people intentionally create a Seq[Product with Serializable]? Its not the > end of the world for me, the pros of Scala far out weight the flaws. > However when trying to persuade new people of the benefits of Scala these > sorts of surprises can potentially be a deal breaker. One of our prime > selling points with Scala is the early detection of type errors. > I agree that it would be nice to flag such types but the fact that they aren't flagged isn't the fault of the type inference, it's the lack of additional code to check the inferred type after the fact. > Perhaps part of the problem is that "If" and "match" expressions can not > be explicitly type parametised. > You can use an ascription... ((...): Type) -- > You received this message because you are subscribed to the Google Groups > "scala-language" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.