Bit by Flexibility: Implicit Conversions to Java with Scala 2.8
Scala 2.8 includes a library that helps implicitly convert Scala objects to
Java objects so you can keep your data in Scala-land while still using Java API
calls. Just import this package in your code:jj
The problem is sometimes the conversion library fails at compile time because
there are just too many possible conversions it can make. It can’t decide
between all the possibilities. Talk about being a victim of your own success!
Here’s an example: I have a scala.Iterable of items, and I want to implicitly
convert it to a java.lang.Iterable
But the implicit conversion dies here with the following message:
So here’s the fix: you can wrap your data to indicate the particular conversion
you would like to occur. A list of wrappers is
In my case, I want a java.lang.Iterable, so I’ll wrap it as so:
This removes the ambiguity, allowing the compiler to proceed without baffling
itself by its own cleverness.
I don’t have a deep understanding of the law, but I think the recent closing of
the “Adult Services” section on Craigslist is a fascinating moment to reflect
how complicated and confusing regulating sin is.
MIT is hosting the 2010 Empirical Methods in Natural Langauge Processing
conference this year, and I noticed
a clustering of papers in the program that would make for a fun session,
possibly titled “Linguistic Security”. The session would cover both offense
(what can we tell about you from the language you use) and defense (how can you
hide messages in your word choice).