Question: For instance, how can I write code in ATS that traverses a given string as is done by the following C code:

```
while ((c = *str++) != 0) do_something(c);

```

Answer: 
The following solution is easy, accessible and doesn't require any unsafe features (but it does use one advanced feature: indexed string type).

```
fun
loop {n:int}(p0: string(n)): void =
if string_isnot_empty (p0) then let
  val c = (g0ofg1)(string_head(p0))
  val p0 = string_tail(p0)
in
  do_something(c); loop(p0)
end

```

Full code: <https://glot.io/snippets/ejpwxk2xzx>
The following solution makes use of UNSAFE but it should be really easy to access:

```
staload
UNSAFE =
"prelude/SATS/unsafe.sats"

fun
loop(p0: ptr): void = let
  val c = $UNSAFE.ptr_get<char>p0)
in
  if isneqz(c) then (do_something(c); loop(ptr_succ<char>(p0)) else ()
end

val () = loop(string2ptr(str))

```