[Gllug] trashman - a trash management utility for Linux filesystem
Nix
nix at esperi.org.uk
Fri Feb 3 21:32:11 UTC 2006
On Thu, 2 Feb 2006, Richard Jones mused:
> On Thu, Feb 02, 2006 at 08:24:22AM +0000, Nix wrote:
>> Ooo! I know classic ML was awful at it...
>
> My classic ML is not so good. Sticking with OCaml though ...
>
> This C code:
>
> struct foo {
> struct bar *ptr;
> }
>
> foo_a->ptr = foo_b;
>
> is exactly equivalent to this in OCaml:
>
> type foo = {
> mutable ptr : bar;
> }
>
> foo_a.ptr <- foo_b;
... although quite why one would use ML and then write C in it
is... unclear to me. ;)
> Even the in-memory representation and the code generated to
> read/update the pointer is identical.
Nifty! Plus of course OCaml is probably more amenable to optimizations
(not that that matters in disk-bound filesystem code!)
One of the reasons I'm using a lesser language is actually to encourage
me to use *no* non-transient in-memory data structures, so the stupider
the language's type system the happier I am, to a certain degree. If I
ensure that all storage is on the disk, then making Recant a distributed
filesystem is dog simple: just start up Recant daemons on other machines
and connect them to the same database. (No distributed locking, though;
FUSE doesn't pass the POSIX locking stuff down to userspace.)
Plus, threading it also becomes a doddle, especially with the aid of the
lovely `transactor' template in libpqxx, which repeatedly reinvokes a
deadlocking transaction until it succeeds (within certain bounds): of
course the code that implements that transaction should not modify any
global state!
But I'll have a look at OCaml anyway. :)
> The only thing OCaml won't let you do is to create a foo without
> initializing the ptr field (which you can obviously do in C just by
How simply *terrible*.
> using malloc and then not bothering to initialize the field). This
> "limitation" of OCaml is probably to be regarded as a Good Thing ...
Yeah, I tend to dislike memory allocation bugs as much as the next man
:)
--
`I won't make a secret of the fact that your statement/question
sent a wave of shock and horror through us.' --- David Anderson
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list