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

How do you get compile-time errors, which are the point of statically typed languages?


They're currently working on "typed actors" which will hopfully absolve the Scala world of these awful TypeDangerous actors, thus redeeming the name "TypeSafe"


If you cast, you don't. If you pattern match, you do. Pattern matching allows you to determine the type of an object and extract its contents, by "testing" which type it is. Everything is typechecked.


I know what pattern matching is; I'm not unfamiliar with Scala or other statically-typed languages with pattern matching. I was referring to what user morsch is saying in his/her comment.

The problem I see is in the sender, who doesn't know if the message makes sense for the receiver. Isn't this like programming in Smalltalk or Ruby, with their "doesNotUnderstand" or "method_missing"? How does this mesh with Scala's static typing, which aims to give you compile-time errors when you screw up?


The compiler prevents you from doing

  case x: Warble => modifyTheWargle(x)
but it doesn't stop you from sending out a Wargle to the actor that only expects Warbles.




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

Search: