[darcs-devel] Moving system code to Haskell

Ian Lynagh igloo at earth.li
Sat Aug 27 17:19:19 PDT 2005


On Sat, Aug 27, 2005 at 07:41:00PM -0400, David Roundy wrote:
> 
> On the other hand, the haskell code looks like it's got somewhat fewer
> opportunities for overflowish errors, which is definitely a plus (looking
> in particular at the snprintf, and remembering that at one time we had an
> snprintf that was overflowing its null character).

Just to expand on this, my motivations for removing C code include:

The standard C hassles like overflows etc, as you mention.

Avoiding annoying conversions and incorrect types as much as possible
when communicating between the C and Haskell worlds (I've fixed a bunch
of mismatches already. We still have a number left, but I'm hoping to
get rid of them by converting code to Haskell instead).

Not having to worry about trampling on errno, either saving it in the C
code or doing other things in Haskell that destroy it before we read it
(this, after a (sloppy_)?atomic_create call, was the cause of Jason's
recent bug that made me get around to this, incidentally).

I think the Haskell code was also more concise (I could be
misremembering this), mainly due to having to do explicit memory
management in C. It also means we don't need to have stuff spread out
over .hs, .c and .h files.

And the Haskell is, of course, better typed.

> (In other words, I'm pretty much flip-flopping on the question...)

:-)

Anyone else got an opinion?

Are we only talking about
    maybe_relink atomic_create sloppy_atomic_create
(i.e. neither reverting others that have been converted, nor keeping
others that haven't been converted yet) BTW?


Thanks
Ian





More information about the darcs-devel mailing list