NICKLE(1) General Commands Manual NICKLE(1) (NAME) nickle - (SYNOPSIS) nickle [--help|--usage] [-f file] [-l library] [-e expr] [-V] [ script ] [--] [arg ...] (DESCRIPTION) Nickle . Nickle . C . C . (USAGE) ( ) Nickle . argv Nickle . Nickle . : --help,--usage / . ParseArgs Nickle Nickle . -f,--file file file Nickle . -l,--library library library Nickle . . -e,--expr expr expr . -V,--version Nickle . -- argv. (SYNTAX) newline <<>> . Newline ( : ()if ()twixt else ). ; . . Nickle . name _ E S T . X,X,...,X X . (Comments): C /* */ # . (Operands): (real number) . . . << >> : ( ) ()imprecise . (octal number) 0 ( 014 12 ). (hexadecimal number) "0x" ( 0x1a 26 ). (string) C. . ( ) "\n" "\r" "\b" "\t" "\f" . name . name() name(E,E,...,E) . (call-by-value) : C . desc name T name = value : . desc : (visibility) (storage class) (type) ( ) . QUALIFIERS . : VALUES . Nickle (union) C : int[*,*] name = {{0,1},{2,3}} int[2,2] name = {{0...}...} . : . . C . C . (Visibility): public ( ) public (namespace) (import) . Namespaces . protected ( ) protected import . Namespaces . (Lifetime): auto auto : . auto . . static static : . static . Nickle static ( static C) ( static C). global global : . global . . static global Nickle C C (first class) . Nickle . (OPERATORS) Nickle : A[E,E,...,E] E- A E1-/E2-/ . C NAWK . struct.tag (Structure dereference). struct->tag C. ============= ++ -- / . . - . ! E . E ! . . * E (Pointer dereference). & E (Reference construction). ============= (U) E union U E. ============= ** . . . real . (type-unsound) Nickle : 2 ** -3 integer rational . : int x = 2 ** -3; ============= * / // % . . rational : int . C . : x // y == y > 0 ? floor (x / y) : ceil(x / y) : x % y = x - (x // y) * y ============= + - . ============= << >> . . : x << y = x * 2 ** y x >> y = x // 2 ** y ( ) (sign-extending). ============= <= >= < > . ============= == != . ============= : & AND . ( ). ^ XOR . AND . | OR . AND . && AND (Short-circuit). || OR (Short-circuit). E ? E : E : (true) . fork E ( ) (thread). Thread . = += -= *= /= //= %= **= <<= >>= ^= &= |= . . x = y x = x y E , E . Nickle C "" Java . : poly integer rational real string continuation void . void . ML "unit" C . poly (supertype) ( ) . file semaphore thread ADT File Thread : . : Nickle (polymorphic) : . Nickle . . poly . . int . rational . real . Nickle . imprecise(n) real n imprecise(n,p) real p . T[] T . Nickle . T[*] T. C Nickle . Nickle . T[*,*,...,*] T. "*" . "T[]" . T[E,E,...,E] . . . T0() T0(T,T,...,T) T0 . . T0() T0(T,T,...,T ...) . : varargs . *T T. Nickle : . (0 null) . C "*" "[]" "()" : . struct {T name; T name; ...} . T : poly . union {T name; T name; ...} " " (disjoint union) . Pascal datatype ML union C: . (T) . Typedef: C typedef . : typedef T typename; T Nickle . typename . (VALUES) Nickle . . file semaphore continuation : Nickle . TYPES Nickle " " : . . ( ). . (Arrays): [E] ( ) E . E . [E]{V,V,...,V} E V . . [E]{V,V,...,V...} . E . V V . . [*]{V,V,...,V} . . [E,E,...,E] [*,*,...,*] . "*" : . : . (T[E]) (T[E,E,...,E]) (T[E]){E,E,...,E} (T[E,E,...,E]){{E,...},...,{E,...}} T. . . C . (T[*]){E,E,...,E} (T[*,*,...,*]){{E,...},...,{E,...}} T . (Pointers): 0 (null) . &V &A[E,E,...,E] &S.N . *T T . *P P . C . (Functions): (T func(){S;S;...S;}) (T func(T name,T name,...T name){S;S;...S;}) : . . poly . (call-by-value) : . T function name(T name,T name,...,T name){S;S;...S;} . (Syntactic sugar) : T(T,T,...T) name = (T func(T name,T name,...T name){S;S;...S;}); T function name(T name, T name ...) : . "" T ( poly) . (Structures): (struct { T name; T name; ...T name; }){name = E; name = E; ...name=E;} . . C. (Unions): .IP (union { T name; T name; ...T name; }.name) E union .name E . E name . (STATEMENTS) C . Nickle . E; . {S ... S} . if (E) S . if (E) S . else S else . else if() twixt() . while (E) S while C. do S while (E); do C. for (opt-E; opt-E; opt-E) S for C. switch (E) { case E: S-list case E: S-list ... default: S-list } case C. case . case switch default switch . twixt(opt-E; opt-E) S twixt(opt-E; opt-E) S else S (true) twixt() . (false) else . twixt() . twixt() ( ) twixt() continuation break. ( "finally" Java .) try S; try S catch name (T name, ...) { S; ... }; try S catch name (T name, ...) { S; ... } ... ; S . catch catch catch . try catch . catch . catch try . else catch try-catch . raise name(name, name, ..., name) . ; (null statement). break; for/do/while/switch/twixt. twixt (leave) . continue; for/do/while. return E; E . (Namespaces): Java C++ Nickle namespace ( ) . Nickle namespace . opt-P namespace N { S ... } S N . P public : N . extend namespace N { S ... } N public S . public . public : namespace::namespace::...::namespace::name . - C++ . Java name.name.name : . import N; N : public ( ). (BUILTINS) Nickle . C Nickle . : ADT ( ) . (Top-Level Builtins): int printf(string fmt, poly args...) File::fprintf(stdout, fmt, args ...) . string function gets () File::fgets(stdin) . string function scanf (string fmt, *poly args...) File::vfscanf(stdin, fmt, args) . string function vscanf (string fmt, (*poly)[*] args) File::vfscanf(stdin, fmt, args) . real imprecise(rational value) real . real imprecise(rational value, int prec) real . int string_to_integer(string s) int atoi(string s) s . s (hexadecimal) (octal) (binary) . int string_to_integer(string s, int base) int atoi(string s, int base) s . 0 . . int putchar(int c) File::putc(c, stdout) . int sleep(int msecs) (thread) msecs . 1 0 . int exit(int status) Nickle . . int dim(poly[*] a) a dim() a . int[] dims(poly[] a) a dims() a . dim(dims(a)) a . *poly reference(poly v) v <<>> (box) . rational string_to_real(string s) rational atof(string s) s . number abs(real v) v . . int floor(real v) v . v real . int ceil(real v) v . v real . int exponent(real v) () v . rational mantissa(real v) v m 0 <= m <= 0.5 . int numerator(rational v) v : v = n/d n . int denominator(rational v) v : v = n/d d . int precision(real v) v ..IP "int sign(real v)" v -1 1 . int bit_width(int v) abs(v) . int is_int(poly v) (Type predicate). int is_rational(poly v) : is_rational(1) 1 . int is_number(poly v) . int is_string(poly v) . int is_file(poly v) . int is_thread(poly v) . int is_semaphore(poly v) . int is_continuation(poly v) . int is_array(poly v) . int is_ref(poly v) : . (misfeature) . int is_struct(poly v) . int is_func(poly v) . int is_void(poly v) . int gcd(int p, int q) (GCD) p q . . int xor(int a, int b) a ^ b . xor Nickle . poly setjmp(continuation *c, poly retval) setjmp() longjmp() continuation (ADT) . setjmp() longjmp() C longjmp() (!): continuation setjmp() . setjmp() continuation . void longjmp(continuation c, poly retval) longjmp() setjmp() continuation longjmp() . string prompt (prompt) (top-level) . "> ". . "> " "+ " "- " . string prompt2 . "+ ". string prompt3 . "- ". string format printf() . "%g". string version Nickle . string build Nickle "yyyy/mm/dd" "?". file stdin . file stdout . file stderr . (Exceptions): Nickle . exception uninitialized_value(string msg) . exception invalid_argument(string msg, int arg, poly val) arg val . exception readonly_box(string msg, poly val) val. exception invalid_array_bounds(string msg, poly a, poly i) a i. exception divide_by_zero(string msg, real num, real den) num den den == 0 . exception invalid_struct_member(string msg, poly struct, string name) name struct . exception invalid_binop_values(string msg, poly arg1, poly arg2) arg1 arg2 . exception invalid_unop_values(string msg, poly arg) arg. (Builtin Namespaces): Math Math C . . real pi . protected real e . e (protected) Math::e (top level) . real function sqrt(real v) () v . real function cbrt(real v) () v . real function exp(real v) e**v . real function log(real a) v e**v == a . a invalid_argument . real function log10(real a) v 10**v == a . a invalid_argument . real function log2(real a) v 2**v == a . a invalid_argument . real function pi_value(int prec) prec . real function sin(real a) a . real function cos(real a) a . void function sin_cos(real a, *real sinp, *real cosp) sin(a) cos(a) sinp cosp . 0 . . real function tan(real a) a . tan(pi/2) : . real function asin(real v) a sin(a) == v . real function acos(real v) a cos(a) == v . real function atan(real v) a tan(a) == v . real function atan2(real x, y) a tan(a) == x / y . y == 0 . real function pow(real a, real b) **. File File . int function fprintf(file f, string s, ....) fprintf() stdio . fprintf() printf() stdio : %c %d %e %x %o %f %s %g %v . . . (Format Letters): .IP %c (0..255) ASCII . %d . %x () . %o () . %e . %f . %s . %g . : digits . . digits.digits ( ) . . - . * fprintf() . file function string_write() . int function close(file f) f . int function flush(file f) f (flush) . int function getc(file f) f . int function end(file f) f (EOF) true false . int function error(file f) f true false . int function clear_error(file f) f . file function string_read(string s) s . string function string_string(file f) f string_read() string_write() . . file function open(string path, string mode) path mode fopen() UNIX stdio . stdio : "r" "w" "x" "r+" "w+" "x+". integer function fputc(integer c, file f) c f . integer function ungetc(integer c, file f) c f . integer function setbuf(file f, integer n) f n n . string function fgets (file f) f . file function pipe(string path, string[*] argv, string mode) path pipe . mode pipe "r" "w" . argv argv[0] . int function print (file f, poly v, string fmt, int base, int width, int prec, string fill) v f fmt base width prec fill . File::fprintf() . int function fscanf(file f, string fmt, *poly args...) args f fmt . scanf() UNIX stdio : "%d" "%e" "%f" "%c" "%s" . int function vfscanf (file f, string fmt, (*poly)[*] args) f fmt args fscanf() . Thread Thread threads () . . fork(E) . fork . Thread . int function kill(thread list...) list . . . int function trace(poly list...) list . (default continuation) . . int function cont() . thread function current() . int function list() stdout . int function get_priority(thread t) t . thread function id_to_thread(int id) id 0 . poly function join(thread t) t . int function set_priority(thread t, int i) t i . : . (pre-emptively) . Semaphore Semaphore (built-in ADT) . . signal() wait() . "count" () . semaphore function new(int c) c . c c . c . semaphore function new() semaphore(0) . int signal(semaphore s) s . s s . 1 . int wait(semaphore s) s . s . 1 . int test(semaphore s) wait() s . 0 s 1 . String String ADT . int function length(string s) s . string function new(int c) c . string function new(int cv[*]) cv . int function index(string t, string p) () p t p t -1 . string function substr(string s, int i, int l) s i ( ) l . l i . PRNG PRNG . RC4 (bootstrapped) . . ( .).IP "void function srandom(int s)" ( ) (seed) . void function dev_srandom(int nbits) nbits . UNIX /dev/urandom . ( UNIX) . int function randbits(int n) n- 0..(2**n)-1 . RSA . int function randint(int n) 0..n-1 . void function shuffle(*(poly[*]) a) (.. ) a . Command Command . . string library_path (colon) . int function undefine(string name) undefine . name . . int function undefine(string[*] names) names . . int function delete(string name) name 1 . int function lex_file(string path) path Nickle 1 . (include) . int function lex_library(string filename) lex_file() library_path filename . int function lex_string(string code) Nickle code . int function edit(string[*] names) edit . ( ) . int function new(string name, poly func) func name : . int function new_names(string name, poly func) func name : . new() func . int function pretty_print(file f, string[*] names) print . f . int function display(string fmt, poly val) printf() val fmt . History Nickle . History . int function show(string fmt) history . fmt . int function show(string fmt, int count) history . count fmt . int function show(string fmt, int first, int last) history . poly function insert(poly val) val . Environ << >> . Environ . int function check(string name) name 1 0 . string function get(string name) name . invalid_argument . int function unset(string name) name (unset) . string function set(string name, string value) name value . (COMMANDS) Nickle . quit Nickle. quit E Nickle E. undefine NAME {,NAME} . load E E . library E E . NICKLEPATH << (ENVIRONMENT)>> Command::library_path . E # E expr1 expr2. print NAME NAME. . NAME . edit NAME $EDITOR . . history . $n n . history E E . history E,E E . (top level) (debug mode) . . : trace (stack backtrace) where GDB. up ( ) GDB. down ( ) GDB. done . Debug (in scope) . Nickle . collect() (garbage collector). dump(function) function. (ENVIRONMENT) EDITOR edit . NICKLERC .nicklerc nickle . HOME .nicklerc NICKLERC . NICKLEPATH (:) Nickle . library -l . /usr/share/nickle . NICKLESTART Nickle (bootstrap) . /usr/share/nickle/builtin.5c . (EXAMPLES) ( bc): real function exponent(real x) { real a = 1; int b = 1; real s = 1; int i = 1; while (1) { a = a * x; b = b * i; real c = a / b; if (abs(c) < 1e-6) return s; s = s + c; i++; } } e ** x for (i = 1; i < 10; i++) printf ("%g\n", exponent (i)); . (VERSION) 1.99.2 nickle . "2.108" nickle . (BUGS) ** . (bare assignment) : . : > int x = 0; > (int[*]){x = 1} -> (int[*]) { x = 1 } Non array initializer (workaround) : > (int[*]){(x = 1)} [1]{1} . . . (semantics) C . C : . C (misfeature) . . Nickle Keith Packard Bart Massey . Nickle - Keith Packard Bart Massey . . (<<>>) / : . << >> (AS IS) . . . 2026-03-14 NICKLE(1)