This means we can make primitives for reading/writing file handles which
are given the world state, so can be written more safely. Also, a
minimal back end can implement these rather than implementing an entire
FFI.
Updated primitive LReadStr (which can now reasonably be total, like any
foreign function, because it has a world state) and added primitive
LWriteStr.
A ManagedPtr is just like a Ptr, except it points to memory inside
Idris' heap, so doesn't need to be freed. This is useful when you need
to create a structure C side for interacting with a C library, but don't
want to have to explicitly free it.
Also added
registerPtr : (p : Ptr) -> (n : Int) -> ManagedPtr
This moves the n bytes pointed to by p into the Idris heap.
In a non-C backend, or one where memory is managed differently, it's
entirely reasonable for this to be compiled as a no-op. The FFI treats
both Ptr and ManagedPtr as a void* in C.
Can be useful when dealing with values originating in foreign functions.
Intended in particular for checking sending VM in message passing
concurrency.
In addition to removing the superfluous 'isNullString' function,
now that I understand the FFI a bit better, there is a new
'getEnvPair' function that looks into the 'const char** environ'.
Setting, unsetting, and listing all of the environment variables is
now supported.
For edwinb/Idris-dev#331 , allowing a segfault on returning a
null pointer string is very bad. This requires that either the
value is present or it returns Nothing.
PrimIO is the internal primitive, IO is the user version which requires an
explicit World token to be passed in which programmers have no access to
directly.
Fixes#185 and fixes#325