Howdy David & Co.,

One of the *really* nice things about Scala's pattern matching is the
ability to extend pattern matching using extractors. The research is
presented in
http://lampwww.epfl.ch/~emir/written/MatchingObjectsWithPatterns-TR.pdf

The practical aspects allow testing and transforming at pattern matching
time. For example:

object AsInt {
  def unapply(in: String): Option[Int] = try {Some(in.toInt)} catch {case
e: Exception => None}
}

foo match {
  case AsInt(number) => number + 1
  case _ => 0
}

More importantly, one can use extractors to test external things:

object AsJsonFile {
  def unapply(fileName: String): Option[JSON] = ... // find the file, load
it and parse it as JSON
}

What are your thoughts on adding extractors to the pattern matcher?

Thanks,

David

-- 
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to