Array concatenation: Difference between revisions

Line 655:
length m, with elements of type t, and the array must have been
initialized; the second is a similar array of length n. The third
array is uninitialized (thus the "?" character) and must have
length m+n; its type will change to "initialized". *)
 
Line 684:
 
(* We are done. Everything should now work, and the result will be
safe from buffer overruns or underruns, and against accidental misuse of
misuse of uninitialized data. *)
 
}
 
(* arrayconcat2 is a pass-by-reference interface to arrayconcat1. Most*)
fn {t : t@ype}
arrayconcat2 {m, n : nat}
Line 696 ⟶ 697:
m : size_t m,
n : size_t n) : void =
val _ = arrayconcat1 (pfa, pfb, pfc | addrview@ a, addrview@ b, addrview@ c, |
 
addr@ a, addr@ b, addr@ c, m, n)
(* arrayconcat2 is a pass-by-reference interface to arrayconcat1. Most
of the following deals with the arrays being linear-typed objects:
if one removes the view from an array, a new view has to be
inserted into the array before the routine terminates. This is done
during typechecking; it does not affect the executable code. *)
 
{
prval pfa = view@ a
prval pfb = view@ b
prval pfc = view@ c
val _ = arrayconcat1 (pfa, pfb, pfc | addr@ a, addr@ b, addr@ c,
m, n)
prval _ = view@ a := pfa
prval _ = view@ b := pfb
prval _ = view@ c := pfc
}
 
(* Overloads to let you say "arrayconcat" for either routine above. *)
Line 749 ⟶ 735:
<pre>$ patscc -O2 -DATS_MEMALLOC_LIBC arrayconcat.dats && ./a.out
1, 2, 3, 5, 6, 7, 8</pre>
 
 
 
=={{header|AutoHotkey}}==
1,448

edits