It is possible to use pattern matching in Nimrod? If not, are there plans to include it?
For those who ignore what am i talking about, this is pattern matching in scala:
def listAnalysis(list: List[Any]) = list match {
case Nil => "empty"
case 'a' :: tail => "starting by 'a'"
case (head:Int) :: _ if head > 3 => "starting by an int greater than 3"
case (head:Int) :: _ => "starting by an int"
case _ => "whatever"
}
Pattern matching is possible with a macro as I show in my article: http://www.drdobbs.com/open-source/nimrod-a-new-systems-programming-languag/240165321
Now please ask the Scala guys whether their form of pattern matching supports exhaustiveness checking. Tell them Nimrod's “case“ statement does it. ;-)
Scala supports exhaustiveness checking when an object hierarchy is marked with the sealed keyword, for example:
scala> sealed trait T; object A extends T; object B extends T
defined trait T
defined object A
defined object B
scala> def f(t: T) = t match { case A => }
<console>:9: warning: match may not be exhaustive.
It would fail on the following input: B
def f(t: T) = t match { case A => }
^
f: (t: T)Unit