dimitriv / Ziria

A domain-specific-language and compiler for low-level bitstream processing.
92 stars 18 forks source link

Issues in /doc/UserGuide/language #111

Closed Dom-Skinner closed 9 years ago

Dom-Skinner commented 9 years ago

In the first example of a map:

fun f(x : int) {
  var y : int = 42;
  y := y + 1;
  return (x+y);
}

let comp main = read >>> map f >>> write

The second line is missing a colon and should be

var y : int := 42;

The "Just return a value" code:

fun comp f(x : int) {
  var y : int := 0;
      { a <-     { do { y := y + x; }
                 ; z <- take
                 ; emit (z+y);
                 ; return y
                 }
      ; emit a
      }
} ...

has an extra semi-colon, i.e. ; emit(z+y); should just be ; emit(z+y)

The if statement does not run as described:

fun comp f() {
       { x <- take
       ; if (x > 0) then
            emit (x+1)
         else return ()
       }
}
let comp main = read >>> f() >>> write

This takes only the first element and applies the if statement to it. It says in the description that: "The effect of this computer is that it will keep on incrementing all positive values of the input stream and emitting those to the output stream. However, once it meets the first non-positive one the whole computation will stop."

Finally, the for loop code:

fun comp f() {
  for n in [0:4]
    { x <- take; emit x }
}
fun comp g(y : inr) }
  for n in [0,y]
    emit n -- n is bound in the body
}
let comp main = read >>> { f() ; g(100) } >>> write

should be

fun comp f() {
  for n in [0:4]
    { x <- take; emit x }
}

fun comp g(y : int) {
  for n in [0,y]
    emit n -- n is bound in the body
}

let comp main = read >>> { f() ; g(100) } >>> write

(Where I have replaced g(y: inr) } with g(y:int) {)