tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 9e5cddd29b87aaf3b02a69c6d6bc8aa5daf19d8d
parent 4dac1c2d761c9cfc5b801a0502d0a2e9b650ee72
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Mon,  1 Jun 2020 12:46:48 -0700

Rename type to typeof

Diffstat:
doc/tisp.1.md | 2+-
tibs/doc.tsp | 4++--
tibs/lib.tsp | 22+++++++++++-----------
tisp.c | 6+++---
4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/doc/tisp.1.md b/doc/tisp.1.md @@ -201,7 +201,7 @@ the body to be run if and only if the condition is met. Used for if/elseif/else statements found in C-like languages and `if`,`when`,`unless`,`switch` macros in Tisp. -#### type +#### typeof Returns a string stating the given argument's type. Used to create `type?` individual functions. diff --git a/tibs/doc.tsp b/tibs/doc.tsp @@ -23,8 +23,8 @@ (cond "(cond . (expr . body))" "conditional statement") - (type - "(type val)" + (typeof + "(typeof val)" "return a string stating the argument's type") (get "(get val prop)" diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -36,18 +36,18 @@ ;;; Types (define (any? x) t) -(define (void? x) (= (type x) "void")) -(define (nil? x) (= (type x) "nil")) +(define (void? x) (= (typeof x) "void")) +(define (nil? x) (= (typeof x) "nil")) (define empty? nil?) -(define (integer? x) (= (type x) "integer")) -(define (decimal? x) (= (type x) "decimal")) -(define (ratio? x) (= (type x) "ratio")) -(define (string? x) (= (type x) "string")) -(define (symbol? x) (= (type x) "symbol")) -(define (primitive? x) (= (type x) "primitive")) -(define (function? x) (= (type x) "function")) -(define (macro? x) (= (type x) "macro")) -(define (pair? x) (= (type x) "pair")) +(define (integer? x) (= (typeof x) "integer")) +(define (decimal? x) (= (typeof x) "decimal")) +(define (ratio? x) (= (typeof x) "ratio")) +(define (string? x) (= (typeof x) "string")) +(define (symbol? x) (= (typeof x) "symbol")) +(define (primitive? x) (= (typeof x) "primitive")) +(define (function? x) (= (typeof x) "function")) +(define (macro? x) (= (typeof x) "macro")) +(define (pair? x) (= (typeof x) "pair")) (define (atom? x) (not (pair? x))) (define (cons? x) (and (pair? x) (not (pair? (cdr x))))) (define (list? x) (if (pair? x) (list? (cdr x)) (not x))) diff --git a/tisp.c b/tisp.c @@ -909,10 +909,10 @@ prim_cond(Tsp st, Hash env, Val args) /* return type of tisp value */ static Val -prim_type(Tsp st, Hash env, Val args) +prim_typeof(Tsp st, Hash env, Val args) { Val v; - tsp_arg_num(args, "type", 1); + tsp_arg_num(args, "typeof", 1); if (!(v = tisp_eval(st, env, car(args)))) return NULL; return mk_str(st, type_str(v->t)); @@ -1158,7 +1158,7 @@ tisp_env_init(size_t cap) tsp_env_fn(eval); tsp_env_name_fn(=, eq); tsp_env_fn(cond); - tsp_env_fn(type); + tsp_env_fn(typeof); tsp_env_fn(get); tsp_env_fn(lambda); tsp_env_fn(macro);