On 27-Nov-2000, Ashley Yakeley <ashley@semantic.org> wrote:
> >This is an issue, but it arises in any "pure" language with a foreign
> >language interface.
>> Not necessarily, the functions just need to be typed correctly. In the
> case of a non-safe or imperative function, that's going to be of the
> form "a -> IO b" (or "IO a -> IO b" if you prefer the more powerful arrow
> model).
>> No safety needs to be sacrificed.
I would agree that no purity (referential transparency) needs to be
sacrificed. The IO monad preserves referential transparency pretty
well.
Safety is another issue. If by safety we mean "memory safe" (cannot
use invalid pointers) then how can the IO monad possibly help?
We can dereference an invalid pointer inside or outside the IO monad --
it doesn't matter, the program still crashes. Surely then we cannot call a
foreign language interface "safe" just because it gives each foreign
function IO types.
Typically both impure (non-referentially transparent) and plain old
unsafe code can be made into pure & safe code by a bit of sequencing
(helped by a monad) and an nice pure wrapper interface (and sometimes
even unsafePerformIO to hide the now unnecessary monads).
But the issue then arises that if you use the IO monad for the sequencing
of raw, potentially unsafe code, how are developers supposed to be able
to tell it apart from safe IO code?
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd@cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #