Standard ML of New Jersey


The UNSAFE_ARRAY signature


Synopsis

signature UNSAFE_ARRAY

For those of you that don't mind a little insecurity if only your array accesses don't have bounds checks, here are some unchecked operations on arrays.

These operations work on ordinary arrays, so you can mix checked and unchecked operations on the same arrays.

In an ideal world (which we're working on, in principle) the compiler would let you use the ordinary checked operations and then optimize the checks away in a safe and efficient manner.


Interface

val sub : ('a array * int) -> 'a
val update : ('a array * int * 'a) -> unit
val create : (int * 'a) -> 'a array

Description

sub (a, i)
Fetch the ith element of a. If i is negative or greater than or equal to the length of a, the results will be unpredictable and may corrupt the further execution of the ML program.

update (a, i, x)
Store x into the ith element of a. If i is negative or greater than or equal to the length of a, the results will be unpredictable and may corrupt the further execution of the ML program.

create (i, x)
Create an array of i elements, with every slot initialized to x. If i is negative or greater than the largest array size that the system can represent the results will be unpredictable and may corrupt the further execution of the ML program.


See Also

Array

[ Top | Parent | Contents | Index | Root ]

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