[MLton] Continuations and MLton.Vector.create

Stephen Weeks MLton@mlton.org
Tue, 28 Mar 2006 13:55:18 -0800


> Looking at the proposed create function made me think about
> continuations. So, I devised the following program:
...
> Under MLton it prints
> 
>   111121111
>   111121111
> 
> and under SML/NJ (v110.57) it prints
> 
>   111121111
>   111111111
> 
> With s/Vector/Array both SML/NJ and MLton produce the same output.

Yep.  I long ago decided it was not worth the complexity or
performance cost to preserve the immutable behavior of Vector.tabulate
(and related functions) in the presence of callcc.

In fact, if you look at the implementation of tabulate in
basis-library/arrays-and-vectors/sequence.fun, you will see the
following comment,

  (* This code is careful to use a list to accumulate the 
   * components of the array in case f uses callcc.
   *)

But the code associated with that comment was itself commented out
long ago.