2.8.0 Upgrades

1 view
Skip to first unread message

Josh Suereth

unread,
Jun 21, 2009, 8:21:16 PM6/21/09
to sca...@lists.scalaforge.org, scala...@googlegroups.com
All,

I've started a wiki article to work through upgrading the scalax.io interfaces for 2.8.0 features.   Please let me know your thoughts!

http://wiki.github.com/eengbrec/Scalax.IO/upgraded-io-design-for-280-features

- Josh

Erik Engbrecht

unread,
Jun 27, 2009, 4:28:43 PM6/27/09
to Josh Suereth, sca...@lists.scalaforge.org, scala...@googlegroups.com
I think the trait File should be split apart so that files and directories have separate traits as follows because there are operations you can perform on files that you can't perform on directories and vice-versa.

trait Path {
  // methods common to both Files and Directories
}

trait Directory extends Path {
  // directory specific methods
}

trait File extends Path {
  // file specific methods
}

I'll post some updates later on tonight.

Erik Engbrecht

unread,
Jun 27, 2009, 8:09:12 PM6/27/09
to Stepan Koltsov, Josh Suereth, sca...@lists.scalaforge.org, scala...@googlegroups.com
re: performance
The "wrongness" of such a solution depends on what your objectives are.  In many cases the added type-safety would outweigh the performance impact.  Assuming there is a performance impact.  I don't see why the API couldn't be designed to avoid the isDirectory calls where they aren't wanted.  I can think of a couple different ways to do it.

re: isDirectory vs pattern matching
People have their preferences.  I don't see why both can't be supported.

re: underlying issue
What's more important:  Performance or type safety?  Low-level access or "doing the right thing?"  I lean toward type safety and doing the right thing because people can always drop down the Java APIs.  I don't see a lot of value in creating wrapper classes that just mimic the objects they wrap.

On Sat, Jun 27, 2009 at 6:39 PM, Stepan Koltsov <yo...@mx1.ru> wrote:
On Sun, Jun 28, 2009 at 00:28, Erik Engbrecht<erik.en...@gmail.com> wrote:
> I think the trait File should be split apart so that files and directories
> have separate traits as follows because there are operations you can perform
> on files that you can't perform on directories and vice-versa.
> trait Path {
>   // methods common to both Files and Directories
> }
> trait Directory extends Path {
>   // directory specific methods
> }
> trait File extends Path {
>   // file specific methods
> }
> I'll post some updates later on tonight.

It is wrong, because of two reasons: performance and useability.

Perfornane: When you listing directory, you only get file names. To
get file type you have to call isDirectory for each file in that
directory. It could be slow.

Useability. Some people prefer calling isDirectory than doing pattern matching.

S.



--
http://erikengbrecht.blogspot.com/

Josh Suereth

unread,
Jun 28, 2009, 9:46:49 AM6/28/09
to scala...@googlegroups.com, Stepan Koltsov, sca...@lists.scalaforge.org, scala...@googlegroups.com
I see the path trait becoming java's file class.  Pattern matching against files and directries could be handy.

I'm in the fence with this one.  However I think a well designed path trait (Composite pattern) + pattern matching could win out here.

Besides performance (against the spoon to be obsolete java file API). Are there anyother reasons?)

Sent from my iPhone

Erik Engbrecht

unread,
Jun 28, 2009, 10:41:12 AM6/28/09
to scala...@googlegroups.com, Stepan Koltsov, sca...@lists.scalaforge.org
What I have (locally) right now is looking like:

trait Location {
  // stuff common to files and directories
}

trait File extends Location {
  // stuff specific to files
  // kind of like JSR203 FileRef only with the stuff from JSR203 Path that applies to Files
}

trait Directory extends Location {
  // stuff specific to directories
}

trait Path extends Location {
  // stuff roughly equivalent to a JSR203 path, objects that can be a File or a Directory
}

Then there's the java.io.File wrappers which form a parallel hierarchy, along with mixins so implementation isn't duplicated between File/Directory and Path.

Josh Suereth

unread,
Jun 28, 2009, 10:59:03 AM6/28/09
to scala...@googlegroups.com
Can you push a branch so I can take a look?  It sounds like the right way to go is to make a JSR203 friendly API and port to using it under the covers with java 7.

Sent from my iPhone

Erik Engbrecht

unread,
Jun 28, 2009, 11:01:25 AM6/28/09
to scala...@googlegroups.com
...soon as it compiles again...maybe 11:30-ish...
--
http://erikengbrecht.blogspot.com/

Erik Engbrecht

unread,
Jun 28, 2009, 11:49:15 AM6/28/09
to scala...@googlegroups.com
the changes are there...go take a look
--
http://erikengbrecht.blogspot.com/
Reply all
Reply to author
Forward
0 new messages