Friday, October 5, 2012

Scala-IO Core: Unmanaged Resources

The main design of Scala-IO is around automatic closing of resources each time a resource is accessed in order to ensure that a programmer cannot unintentionally leave resources open in the face of exceptions or other unexpected situations. However, there are cases where the Scala-IO API is desired but the resource management is undesired. The classic case is of reading or writing to System.in and out. Thus Unmanaged resources exist to satisfy this use-case. 

Since unmanaged resources is a less common use-case there is not a factory object like there is for normal managed Resources.  Instead certain objects can be converted to unmanaged resources using the JavaConverters implicit methods as follows:

4 comments:

  1. Jesse, are there any (may be rough) plans wrt pulling scalax.io into official scala distribution (i.e. eliminating x in scalax)?

    ReplyDelete
  2. We hope to do exactly that. I keep the x mainly so as to remind that it is not yet part of the official distribution

    ReplyDelete
  3. Great! Thanks for your efforts! Can we dream about inclusion into 2.10?

    ReplyDelete
  4. Thank you for your great work!

    I helped me a lot since I started my relationships with Scala :)

    And it's very hard to find really clear and valuable lessons.

    ReplyDelete