Skip to content
This repository was archived by the owner on Dec 7, 2019. It is now read-only.

Primitives

Jonathan50 edited this page Dec 19, 2018 · 8 revisions

Do-it provides these built-in procedures (primitives):

Numbers

  • (+ x y) Add x and y.
  • (- x y) Subtract y from x.
  • (* x y) Multiply x and y.
  • (quotient x y) Return floor of x divided by y.
  • (< x y) Test if x is less than y.
  • (= x y) Test if x is equal to y.
  • (> x y) Test if x is more than y.
  • (<= x y) Test if x is less than or equal to y.
  • (>= x y) Test if x is more than or equal to y.

Booleans

  • (not obj) Return #t if obj is false and #f otherwise.

Pointers

  • (peek ptr) Return the word stored at the address ptr.
  • (poke ptr obj) Set the word stored at the address ptr to obj.

Input and output

  • (display string) Print the string string to standard output.
  • (display-line string) Print the string string to standard output followed by a newline.
  • (newline) Print a newline to standard output.

In addition to the primitives provided by do-it, you can call any C procedure from do-it (without any header files!), as long as the procedure's name is all lower case. If it isn't, you can still write a "wrapper" procedure in C. (C++ procedures should be declared as extern "C" to prevent name mangling.) Replace any underscores with hyphens.

Clone this wiki locally