So the sqlite test keeps failing on my mac because the sqlite that
comes with osx doesn't include the ability to test for if a table
exists in a database. So, probably the best thing to do would be to
remove the database first before creating it. However, we don't have
any handy os-independent filesystem commands. Since we need that
anyway, how do you guys think we should implement it? Here's a simple
survey of how others do it:

Python and Ocaml:
Python throws most it's os interaction into os.py which makes it a bit
unwieldy. Ocaml   does basically the same thing by putting it all in
Unix. I'm betting I don't need to go into too much detail. Since they
both implement one main location for everything, some functions aren't
implemented, which makes the interface inconsistent. They throw either
OSError for python or Unix_error for ocaml on error.

[python]: http://docs.python.org/lib/os-file-dir.html
[ocaml]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html


Ruby:
Ruby puts all of its filesystem routines in one module called
FileUtils. It's operations can quite high level. For instance, chdir
can optionally take a closure that will cd into the specified
directory, run the closure, and cd to the original dir afterwards.
Pretty much every function takes one of the following: force, noop,
preserve, and verbose. This simplifies having to manually create a lot
of these options.

One interesting idea is that they have some sub-modules that set
default arguments on the operations. For instance, you can use
FileUtils::DryRun where it has the same interface as FileUtils but no
actual modification of the filesystem will take place.

On error, it raises exceptions named after unix's errnor, like
Errno::EEXIST and the like.

[ruby]: http://www.ruby-doc.org/stdlib/libdoc/fileutils/rdoc/index.html


D:
This seems to be similar to Ruby but with less sugar. One nice thing
is that instead of presenting a separate glob function, their listdir
function is overloaded to accept a glob pattern or a regex. Errors are
done by raising a FileException

[d]: http://www.digitalmars.com/d/phobos/std_file.html


Haskell:
It's closer to D than Ruby. The main interesting thing is how errors
are done via monads. See the second link for how it works. Since we
don't have exceptions, this could be an interesting way to do error
handling. Without type inferrence, it could be unwieldy, however.

Another minor interesting note is that they have some predefined
directories, like the home directory, and a function to return an
app's data directory.

[haskell]: 
http://haskell.org/ghc/docs/latest/html/libraries/base/System-Directory.html
[haskell's basic io]: http://www.haskell.org/onlinereport/io-13.html


QT:
This is the only c++ cross platform library I'm vaguely familiar with.
Instead of combining all the filesystem commands like Ruby, D, and
Haskell, QT just puts the file operations in QFile and all the
directory operations in QDir. Public methods operate on the current
file or directory, whereas static methods operate on a string. Other
than that, it's reasonably low level.

Errors are done by returning a bool on if the operation was
successful, and setting a global static member value "error" either
QFile or QDir for more info.

[qt's qfile]: http://doc.trolltech.com/4.3/qfile.html
[qt's qdir]: http://doc.trolltech.com/4.3/qdir.html


I think that pretty much covers everything. So, how shall we do ours?

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to