scalax.io

4 views
Skip to first unread message

Josh Suereth

unread,
Jun 21, 2009, 10:50:32 AM6/21/09
to scala...@googlegroups.com
It appears to me that we need to just keep the scalax.control  ManagedResource package and perhaps the ensuring object. 

It also looks like we should keep around a bit of the scalax.data package.  I'd like to try to use the new collections API as much as possible, or integrate directly into it.


From what I can tell, the code in ManagedResource is nice.  The File APIs are decent.  IMHO we should provide a few layers such that when you need the crazy Java APIs you can dig down, but for general code I'd love to see this.

import scalax.io._

val file = dir('.') / "myfile.txt"
for( line <- file.lines ) {
    //do stuff with line
}

along with the more flexible

for {
   file <- resource(new FileInputStream("myfile.txt")
   byte <- file.bytes
} {
  
}

Any other ideas (this is just top of my head)?

Any other thoughts?

- Josh

Fogus

unread,
Jun 21, 2009, 1:18:05 PM6/21/09
to The Scala BEAST
> val file = dir('.') / "myfile.txt"

How about a convenience object coupled with a string2dir implicit
allowing:

val file = PWD / "somedir" / "myfile.txt"

Of course the original would still be valid.

I'm still wrapping my head around the other example.

-m

Josh Suereth

unread,
Jun 21, 2009, 1:47:59 PM6/21/09
to scala...@googlegroups.com
Both of which are good. I'm hoping to document (or find documentation) for what scalax already does.

Right now I'm just digging through all the ManagedResource code to ensure that it's what we want in our I/O Library for ARM.   It appears to answer many of the troubling questions posed on the Project COIN mailing list.


Anyway, having class File {  def /(arg : String) }   seems to make sense!


I'm also trying to collect ideas from other libraries, like n8han's dispatch.

-Josh
Reply all
Reply to author
Forward
0 new messages