Standard ML of New Jersey


The Unsafe structure


Synopsis

signature UNSAFE
structure Unsafe : UNSAFE

These modules provide unsafe access to data structures and to runtime-system functions. Use of Unsafe by an ML program can cause corruption of the ML execution, which may lead to program crashes or other insecurity.


Interface

structure CInterface : CINTERFACE
structure Object : UNSAFE_OBJECT
structure Poll : POLL
structure Vector : UNSAFE_VECTOR
structure Array : UNSAFE_ARRAY
structure CharVector : UNSAFE_MONO_VECTOR
structure CharArray : UNSAFE_MONO_ARRAY
structure Word8Vector : UNSAFE_MONO_VECTOR
structure Word8Array : UNSAFE_MONO_ARRAY
structure Real64Array : UNSAFE_MONO_ARRAY
val getHdlr : unit -> 'a cont
val setHdlr : 'a cont -> unit
val getVar : unit -> 'a
val setVar : 'a -> unit
val getPseudo : int -> 'a
val setPseudo : ('a * int) -> unit
val blastRead : Word8Vector.vector -> 'a
val blastWrite : 'a -> Word8Vector.vector
val boxed : 'a -> bool
val cast : 'a -> 'b
val pStruct : Object.object ref
val topLevelCont : unit cont ref

Description

getHdlr ()
Get the current exception handler, expressed as an exn cont, that is, a continuation taking an exception as an argument. (There seems to be no reason for the type to be 'a cont in this signature.) Throwing an exn to this continuation will behave as if the exception were raised.

There is nothing inherently unsafe about this (except the bogus use of 'a cont in the signature instead of exn cont. It is even possible to grab the handler, then leave the dynamic scope of the handler, then throw to it, with paradoxical but not unsafe effect.

setHdlr k
Install k, which should be an exn cont, as the current exception handler.

getVar ()
SML/NJ has a special global variable, kept in registers upon most target architectures, used for various purposes by subsystems such as CML or the debugger. This function fetches the contents of the "var".

setVar a
Sets the value of the special global variable.

getPseudo i
Obsolete, do not use.

setPseudo (a, i)
Obsolete, do not use.

blastRead vec
Unpack a data structure from a string.

blastWrite a
Marshall a data structure of arbitrary type into a linear sequence of bytes.

boxed a
Tell whether the representation of a is via a pointer.

cast a
View a as if it had another type.

pStruct
A pointer to the primitive core structure; for use in bootstrapping the interactive system.

topLevelCont
The continuation to which control will be thrown when an interrupt signal (SIGINT, on Unix) is received. Usually, the topLevelCont continuation resumes the interactive loop, but in principle users could install other continuation values in this variable.



[ Top | Parent | Contents | Index | Root ]

Last Modified October 28, 1997
Comments to sml-nj@research.bell-labs.com
Copyright © 1998 Bell Labs, Lucent Technologies