From 47b33f2f3a20f490b7e7aed70ceccc41d959ae6b Mon Sep 17 00:00:00 2001 From: Felix Brendel Date: Sat, 21 Sep 2019 01:24:15 +0200 Subject: [PATCH] fixed the tests with new args --- bin/oo.slime | 11 +- bin/pre.slime | 4 +- bin/pre.slime.expanded | 4 +- bin/sets.slime | 7 +- bin/tests/class_macro.slime.expanded | 28 +- bin/tests/evaluation_of_default_args.slime | 4 +- bin/tests/lexical_scope.slime | 2 +- bin/tests/lexical_scope.slime.expanded | 108 +- manual/built-in-docs.org | 2302 +++++++++----------- src/built_ins.cpp | 68 +- src/env.cpp | 4 +- src/error.cpp | 2 +- src/eval.cpp | 1 + src/main.cpp | 2 +- 14 files changed, 1108 insertions(+), 1439 deletions(-) diff --git a/bin/oo.slime b/bin/oo.slime index f574310..b66ce54 100644 --- a/bin/oo.slime +++ b/bin/oo.slime @@ -1,8 +1,8 @@ -(define-syntax (define-class name-and-members :rest body) +(define-syntax (define-class name-and-members . body) "Macro for creating simple classes." (let ((name (first name-and-members)) (members (rest name-and-members))) - `(set-type + `(set-type! (define ;; The function definition (,(string->symbol (concat-strings "make-" (symbol->string name))) @members) @@ -11,8 +11,8 @@ ;; the body @body (let ,(zip members members) - (set-type - (lambda (:rest args) + (set-type! + (lambda args "This is the docs for the handle" (let ((op (eval (first args)))) (if (callable? op) @@ -21,6 +21,5 @@ ,(symbol->keyword name)))) :constructor))) -(define-syntax (-> obj meth :rest args) +(define-syntax (-> obj meth . args) `(,obj ',meth @args)) - diff --git a/bin/pre.slime b/bin/pre.slime index f4242a4..42c3b90 100644 --- a/bin/pre.slime +++ b/bin/pre.slime @@ -36,7 +36,6 @@ condition is false." (define-syntax (let bindings . body) (define (unzip lists) - (break) (when lists (define (iter lists l1 l2) (define elem (first lists)) @@ -45,7 +44,6 @@ condition is false." (pair (first elem) l1) (pair (first (rest elem)) l2)) (list l1 l2)))) - (iter lists () ())) (define unzipped (unzip bindings)) @@ -152,7 +150,7 @@ ithe sequence as arguemens." (concat-strings module-prefix (symbol->string orig-export-name))))) `(define ,export-name - ,(try (eval orig-export-name) + ,(mytry (eval orig-export-name) (error "The module does not contain" orig-export-name))))) exports)))) diff --git a/bin/pre.slime.expanded b/bin/pre.slime.expanded index 9e5f834..682e072 100644 --- a/bin/pre.slime.expanded +++ b/bin/pre.slime.expanded @@ -6,7 +6,7 @@ (define-syntax (n-times times action) :doc "Executes action times times." (define (repeat times elem) (unless (> 1 times) (pair elem (repeat (- times 1) elem)))) `(begin (unquote-splicing (repeat times action)))) -(define-syntax (let bindings . body) (define (unzip lists) (break) (when lists (define (iter lists l1 l2) (define elem (first lists)) (if elem (iter (rest lists) (pair (first elem) l1) (pair (first (rest elem)) l2)) (list l1 l2)))) (iter lists () ())) (define unzipped (unzip bindings)) `((,lambda ,(first unzipped) (unquote-splicing body)) (unquote-splicing (first (rest unzipped))))) +(define-syntax (let bindings . body) (define (unzip lists) (when lists (define (iter lists l1 l2) (define elem (first lists)) (if elem (iter (rest lists) (pair (first elem) l1) (pair (first (rest elem)) l2)) (list l1 l2)))) (iter lists () ())) (define unzipped (unzip bindings)) `((,lambda ,(first unzipped) (unquote-splicing body)) (unquote-splicing (first (rest unzipped))))) (define-syntax (cond . clauses) (define (rec clauses) (if (= nil clauses) nil (if (= (first (first clauses)) 'else) (begin (if (not (= (rest clauses) ())) (error "There are additional clauses after the else clause!") (pair 'begin (rest (first clauses))))) `(if ,(first (first clauses)) (begin (unquote-splicing (rest (first clauses)))) ,(rec (rest clauses)))))) (rec clauses)) @@ -20,7 +20,7 @@ (define-syntax (define-typed args . body) (define (get-arg-names args) (when args (pair (first args) (get-arg-names (rest (rest args)))))) (let ((name (first args)) (lambda-list (rest args)) (arg-names (get-arg-names (rest args)))) `(define (,name (unquote-splicing arg-names)) (assert-types= (unquote-splicing lambda-list)) (unquote-splicing body)))) -(define-syntax (define-module module-name :exports . body) (let ((module-prefix (concat-strings (symbol->string module-name) "::"))) (eval `(begin (unquote-splicing body))) (pair 'begin (map (lambda (orig-export-name) (let ((export-name (string->symbol (concat-strings module-prefix (symbol->string orig-export-name))))) `(define ,export-name ,(try (eval orig-export-name) (error "The module does not contain" orig-export-name))))) exports)))) +(define-syntax (define-module module-name :exports . body) (let ((module-prefix (concat-strings (symbol->string module-name) "::"))) (eval `(begin (unquote-splicing body))) (pair 'begin (map (lambda (orig-export-name) (let ((export-name (string->symbol (concat-strings module-prefix (symbol->string orig-export-name))))) `(define ,export-name ,(mytry (eval orig-export-name) (error "The module does not contain" orig-export-name))))) exports)))) (define (null? x) :doc "Checks if the argument is =nil=." (= x ())) diff --git a/bin/sets.slime b/bin/sets.slime index 6202036..7e8f200 100644 --- a/bin/sets.slime +++ b/bin/sets.slime @@ -5,8 +5,8 @@ (define key-not-found-index -1) - (define (make :rest vals) - (set-type + (define (make . vals) + (set-type! (if vals (list vals) '(())) @@ -27,7 +27,6 @@ (define (insert! set value) (unless (contains? set value) (set! set (pair (pair value (first set)) ())) - (set-type set :set)) + (set-type! set :set)) set) - ) diff --git a/bin/tests/class_macro.slime.expanded b/bin/tests/class_macro.slime.expanded index c30a550..976cb0b 100644 --- a/bin/tests/class_macro.slime.expanded +++ b/bin/tests/class_macro.slime.expanded @@ -1,14 +1,14 @@ -(import "oo.slime") - -(define-class (vector3 x y z) (define (set-x new-x) (mutate x new-x)) (define (set-y new-y) (mutate y new-y)) (define (set-z new-z) (mutate z new-z)) (define (length) (** (+ (* x x) (* y y) (* z z)) 0.500000)) (define (scale fac) (mutate x (* fac x)) (mutate y (* fac y)) (mutate z (* fac z)) fac) (define (add other) (make-vector3 (+ (-> other x) x) (+ (-> other y) y) (+ (-> other z) z))) (define (subtract other) (make-vector3 (- (-> other x) x) (- (-> other y) y) (- (-> other z) z))) (define (equal? other) (and (= (-> other x) x) (= (-> other y) y) (= (-> other z) z))) (define (scalar-product other) (+ (* (-> other x) x) (* (-> other y) y) (* (-> other z) z))) (define (cross-product other) (make-vector3 (- (* (-> other z) y) (* (-> other y) z)) (- (* (-> other x) z) (* (-> other z) x)) (- (* (-> other y) x) (* (-> other x) y)))) (define (print) (printf :sep " " "[vector3] (" x y z ")"))) - -(define v1 (make-vector3 1 2 3)) - -(define v2 (make-vector3 3 2 1)) - -(assert (= (type v1) (type v2) :vector3)) - -(assert (= (v1 'scalar-product v2) 10)) - -(assert (-> (-> v1 cross-product v2) equal? (make-vector3 -4 8 -4))) - +(import "oo.slime") + +(define-class (vector3 x y z) (define (set-x new-x) (mutate x new-x)) (define (set-y new-y) (mutate y new-y)) (define (set-z new-z) (mutate z new-z)) (define (length) (** (+ (* x x) (* y y) (* z z)) 0.500000)) (define (scale fac) (mutate x (* fac x)) (mutate y (* fac y)) (mutate z (* fac z)) fac) (define (add other) (make-vector3 (+ (-> other x) x) (+ (-> other y) y) (+ (-> other z) z))) (define (subtract other) (make-vector3 (- (-> other x) x) (- (-> other y) y) (- (-> other z) z))) (define (equal? other) (and (= (-> other x) x) (= (-> other y) y) (= (-> other z) z))) (define (scalar-product other) (+ (* (-> other x) x) (* (-> other y) y) (* (-> other z) z))) (define (cross-product other) (make-vector3 (- (* (-> other z) y) (* (-> other y) z)) (- (* (-> other x) z) (* (-> other z) x)) (- (* (-> other y) x) (* (-> other x) y)))) (define (print) (printf :sep " " "[vector3] (" x y z ")"))) + +(define v1 (make-vector3 1 2 3)) + +(define v2 (make-vector3 3 2 1)) + +(assert (= (type v1) (type v2) :vector3)) + +(assert (= (v1 'scalar-product v2) 10)) + +(assert (-> (-> v1 cross-product v2) equal? (make-vector3 -4 8 -4))) + diff --git a/bin/tests/evaluation_of_default_args.slime b/bin/tests/evaluation_of_default_args.slime index aae5501..2bb8cc3 100644 --- a/bin/tests/evaluation_of_default_args.slime +++ b/bin/tests/evaluation_of_default_args.slime @@ -1,7 +1,7 @@ -((lambda (:keys k1 :defaults-to (+ 1 2 3)) +((lambda ((:k1 (+ 1 2 3))) (assert (= k1 6)))) -((lambda (:keys k1 :defaults-to ()) +((lambda ((:k1 ())) (when k1 (assert ())) (assert (= k1 ())))) diff --git a/bin/tests/lexical_scope.slime b/bin/tests/lexical_scope.slime index 72bd244..c7e7057 100644 --- a/bin/tests/lexical_scope.slime +++ b/bin/tests/lexical_scope.slime @@ -32,7 +32,7 @@ ;; key arguments (define (make-key-counter) - ((lambda (:keys var) + ((lambda (:var) (lambda () (mutate var (+ 1 var)) var)) diff --git a/bin/tests/lexical_scope.slime.expanded b/bin/tests/lexical_scope.slime.expanded index 2d897de..2ffa5b3 100644 --- a/bin/tests/lexical_scope.slime.expanded +++ b/bin/tests/lexical_scope.slime.expanded @@ -1,54 +1,54 @@ -(define (make-counter) (let ((var 0)) (lambda () (set! var (+ 1 var))))) - -(define counter1 (make-counter)) - -(assert (= (counter1) 1)) - -(define counter2 (make-counter)) - -(assert (= (counter2) 1)) - -(assert (= (counter2) 2)) - -(assert (= (counter1) 2)) - -(assert (= (counter1) 3)) - -(assert (= (counter2) 3)) - -(assert (= (counter2) 4)) - -(assert (= (counter2) 5)) - -(assert (= (counter1) 4)) - -(assert (= (counter1) 5)) - -(define (g) (define x 0) (lambda () (define temp x) (mutate x (+ x 1)) temp)) - -(define (make-key-counter) ((lambda (:keys var) (lambda () (mutate var (+ 1 var)) var)) :var 0)) - -(define key-counter1 (make-key-counter)) - -(assert (= (key-counter1) 1)) - -(define key-counter2 (make-key-counter)) - -(assert (= (key-counter2) 1)) - -(assert (= (key-counter2) 2)) - -(assert (= (key-counter1) 2)) - -(assert (= (key-counter1) 3)) - -(assert (= (key-counter2) 3)) - -(assert (= (key-counter2) 4)) - -(assert (= (key-counter2) 5)) - -(assert (= (key-counter1) 4)) - -(assert (= (key-counter1) 5)) - +(define (make-counter) (let ((var 0)) (lambda () (set! var (+ 1 var))))) + +(define counter1 (make-counter)) + +(assert (= (counter1) 1)) + +(define counter2 (make-counter)) + +(assert (= (counter2) 1)) + +(assert (= (counter2) 2)) + +(assert (= (counter1) 2)) + +(assert (= (counter1) 3)) + +(assert (= (counter2) 3)) + +(assert (= (counter2) 4)) + +(assert (= (counter2) 5)) + +(assert (= (counter1) 4)) + +(assert (= (counter1) 5)) + +(define (g) (define x 0) (lambda () (define temp x) (mutate x (+ x 1)) temp)) + +(define (make-key-counter) ((lambda (:var) (lambda () (mutate var (+ 1 var)) var)) :var 0)) + +(define key-counter1 (make-key-counter)) + +(assert (= (key-counter1) 1)) + +(define key-counter2 (make-key-counter)) + +(assert (= (key-counter2) 1)) + +(assert (= (key-counter2) 2)) + +(assert (= (key-counter1) 2)) + +(assert (= (key-counter1) 3)) + +(assert (= (key-counter2) 3)) + +(assert (= (key-counter2) 4)) + +(assert (= (key-counter2) 5)) + +(assert (= (key-counter1) 4)) + +(assert (= (key-counter1) 5)) + diff --git a/manual/built-in-docs.org b/manual/built-in-docs.org index 9944bde..3579aa9 100644 --- a/manual/built-in-docs.org +++ b/manual/built-in-docs.org @@ -1,1311 +1,991 @@ -\hrule -* === - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:166:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -Takes 0 or more arguments and returns =t= if all arguments are equal and =()= otherwise. - #+END: -\hrule -* =>= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:182:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =>== - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:199:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =<= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:216:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =<== - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:235:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =+= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:252:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =-= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:264:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =*= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:286:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =/= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:306:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =**= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:326:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =%= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:341:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =assert= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:356:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =define= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:367:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =mutate= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:429:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =vector-length= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:454:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =vector-ref= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:462:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =vector-set!= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:479:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =set!= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:499:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =set-car!= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:521:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =set-cdr!= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:532:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =if= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:543:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =quote= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:563:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =quasiquote= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:568:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =and= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:665:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =or= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:676:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =not= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:687:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =while= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:697:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =lambda= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:775:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =special-lambda= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:787:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =eval= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:795:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =begin= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:807:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =list= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:823:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =vector= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:827:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =pair= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:833:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =first= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:843:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =rest= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:854:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =set-type= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:865:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =delete-type= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:877:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =type= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:884:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =info= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:918:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =show= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:999:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =addr-of= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1011:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =generate-docs= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1017:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =print= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1026:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =read= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1034:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =exit= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1051:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =break= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1062:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =memstat= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1067:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =try= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1071:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =load= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1086:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =import= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1097:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =copy= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1108:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =error= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1116:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =symbol->keyword= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1123:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =string->symbol= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1132:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =symbol->string= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1144:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =concat-strings= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:1153:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =pe= - - - defined in :: =pre.slime:4:40= - - type :: =:macro= - - arguments :: : - - postitional :: =expr= - - docu :: none -\hrule -* =when= - - - defined in :: =pre.slime:23:41= - - type :: =:macro= - - arguments :: : - - postitional :: =condition=: - - rest :: =body= - - docu :: - #+BEGIN: -Special form for when multiple actions should be done if a -condition is true. - -{{{example_start}}} -(when (not ()) - (print "Hello ") - (print "from ") - (print "when!")) - -(when () - (print "Goodbye ") - (print "World!")) -{{{example_end}}} - - #+END: -\hrule -* =unless= - - - defined in :: =pre.slime:30:41= - - type :: =:macro= - - arguments :: : - - postitional :: =condition=: - - rest :: =body= - - docu :: - #+BEGIN: -Special form for when multiple actions should be done if a -condition is false. - #+END: -\hrule -* =n-times= - - - defined in :: =pre.slime:37:35= - - type :: =:macro= - - arguments :: : - - postitional :: =times=, =action= - - docu :: - #+BEGIN: -Executes action times times. - #+END: -\hrule -* =let= - - - defined in :: =pre.slime:54:64= - - type :: =:macro= - - arguments :: : - - postitional :: =bindings=: - - rest :: =body= - - docu :: none -\hrule -* =cond= - - - defined in :: =pre.slime:68:17= - - type :: =:macro= - - arguments :: : - - rest :: =clauses= - - docu :: none -\hrule -* =case= - - - defined in :: =pre.slime:83:17= - - type :: =:macro= - - arguments :: : - - postitional :: =var=: - - rest :: =clauses= - - docu :: none -\hrule -* =define-special= - - - defined in :: =pre.slime:86:81= - - type :: =:macro= - - arguments :: : - - postitional :: =name-and-args=: - - rest :: =body= - - docu :: none -\hrule -* =construct-list= - - - defined in :: =pre.slime:127:14= - - type :: =:macro= - - arguments :: : - - rest :: =body= - - docu :: - #+BEGIN: - -{{{example_start}}} -(construct-list - i <- '(1 2 3 4 5) - yield (* i i)) -{{{example_end}}} - -(construct-list - i <- '(1 2 3 4) - j <- '(A B) - yield (pair i j)) - -(construct-list - i <- '(1 2 3 4 5 6 7 8) - if (= 0 (% i 2)) - yield i) - - #+END: -\hrule -* =apply= - - - defined in :: =pre.slime:132:28= - - type :: =:macro= - - arguments :: : - - postitional :: =fun=, =seq= - - docu :: - #+BEGIN: -Applies the function to the sequence, as in calls the function with -ithe sequence as arguemens. - #+END: -\hrule -* =define-typed= - - - defined in :: =pre.slime:144:16= - - type :: =:macro= - - arguments :: : - - postitional :: =args=: - - rest :: =body= - - docu :: none -\hrule -* =define-module= - - - defined in :: =pre.slime:158:27= - - type :: =:macro= - - arguments :: : - - postitional :: =module-name=: - - keyword :: =exports=: - - rest :: =body= - - docu :: none -\hrule -* =null?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is =nil=. - #+END: -\hrule -* =type=?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =obj=, =typ= - - docu :: - #+BEGIN: -Checks if the argument =obj= is of type =typ= - #+END: -\hrule -* =types=?= - - - type :: =:lambda= - - arguments :: : - - rest :: =objs= - - docu :: none -\hrule -* =assert-types== - - - type :: =:lambda= - - arguments :: : - - rest :: =objs= - - docu :: none -\hrule -* =number?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a number. - #+END: -\hrule -* =symbol?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a symbol. - #+END: -\hrule -* =keyword?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a keyword. - #+END: -\hrule -* =pair?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a pair. - #+END: -\hrule -* =string?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a string. - #+END: -\hrule -* =lambda?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a function. - #+END: -\hrule -* =macro?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a macro. - #+END: -\hrule -* =special-lambda?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a special-lambda. - #+END: -\hrule -* =built-in-function?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a built-in function. - #+END: -\hrule -* =callable?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: none -\hrule -* =end= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: - #+BEGIN: -Returns the last pair in the sqeuence. - -{{{example_start}}} -(define a (list 1 2 3 4)) -(printf (end a)) -{{{example_end}}} - - #+END: -\hrule -* =last= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: - #+BEGIN: -Returns the (first) of the last (pair) of the given sequence. - -{{{example_start}}} -(define a (list 1 2 3 4)) -(printf (last a)) -{{{example_end}}} - - #+END: -\hrule -* =extend= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq=, =elem= - - docu :: - #+BEGIN: -Extends a list with the given element, by putting it in -the (rest) of the last element of the sequence. - #+END: -\hrule -* =extend2= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq=, =elem= - - docu :: - #+BEGIN: -Extends a list with the given element, by putting it in -the (rest) of the last element of the sequence. - #+END: -\hrule -* =append= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq=, =elem= - - docu :: - #+BEGIN: -Appends an element to a sequence, by extendeing the list -with (pair elem nil). - #+END: -\hrule -* =length= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: - #+BEGIN: -Returns the length of the given sequence. - #+END: -\hrule -* =member?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =elem=, =seq= - - docu :: none -\hrule -* =sublist-starting-at-index= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq=, =index= - - docu :: none -\hrule -* =list-without-index= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq=, =index= - - docu :: none -\hrule -* =increment= - - - type :: =:lambda= - - arguments :: : - - postitional :: =val= - - docu :: - #+BEGIN: -Adds one to the argument. - #+END: -\hrule -* =decrement= - - - type :: =:lambda= - - arguments :: : - - postitional :: =val= - - docu :: - #+BEGIN: -Subtracts one from the argument. - #+END: -\hrule -* =range= - - - type :: =:lambda= - - arguments :: : - - keyword :: =from= =(0)=, =to= - - docu :: - #+BEGIN: -Returns a sequence of numbers starting with the number defined by the -key =from= and ends with the number defined in =to=. - #+END: -\hrule -* =range-while= - - - type :: =:lambda= - - arguments :: : - - keyword :: =from= =(0)=, =to= - - docu :: - #+BEGIN: -Returns a sequence of numbers starting with the number defined -by the key 'from' and ends with the number defined in 'to'. - #+END: -\hrule -* =map= - - - type :: =:lambda= - - arguments :: : - - postitional :: =fun=, =seq= - - docu :: - #+BEGIN: -Takes a function and a sequence as arguments and returns a new -sequence which contains the results of using the first sequences -elemens as argument to that function. - #+END: -\hrule -* =reduce= - - - type :: =:lambda= - - arguments :: : - - postitional :: =fun=, =seq= - - docu :: - #+BEGIN: -Takes a function and a sequence as arguments and applies the -function to the argument sequence. This only works correctly if the -given function accepts a variable amount of parameters. If your -funciton is limited to two arguments, use [[=reduce-binary=]] -instead. - #+END: -\hrule -* =reduce-binary= - - - type :: =:lambda= - - arguments :: : - - postitional :: =fun=, =seq= - - docu :: - #+BEGIN: -Takes a function and a sequence as arguments and applies the -function to the argument sequence. reduce-binary applies the arguments -*pair-wise* which means it works with binary functions as compared to -[[=reduce=]]. - #+END: -\hrule -* =filter= - - - type :: =:lambda= - - arguments :: : - - postitional :: =fun=, =seq= - - docu :: - #+BEGIN: -Takes a function and a sequence as arguments and applies the -function to every value in the sequence. If the result of that -funciton application returns a truthy value, the original value is -added to a list, which in the end is returned. - #+END: -\hrule -* =zip= - - - type :: =:lambda= - - arguments :: : - - postitional :: =l1=, =l2= - - docu :: none -\hrule -* =unzip= - - - type :: =:lambda= - - arguments :: : - - postitional :: =lists= - - docu :: none -\hrule -* =enumerate= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =printf= - - - type :: =:lambda= - - arguments :: : - - keyword :: =sep= =(" ")=, =end= =("\n")=: - - rest :: =args= - - docu :: - #+BEGIN: -A wrapper for the built-in function [[=print=]] that accepts a -variable number of arguments and also provides keywords for specifying -the printed separators (=sep=) between the arguments and what should -be printed after the last argument (=end=). - #+END: -\hrule -* =key-not-found-index= - - - defined in :: =alist.slime:28:31= - - type :: =:number= - - value :: =-1= - - docu :: none -\hrule -* =make-alist= - - - type :: =:lambda= - - arguments :: none. - - docu :: none -\hrule -* =make-plist= - - - type :: =:lambda= - - arguments :: none. - - docu :: none -\hrule -* =pprint-alist= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist= - - docu :: none -\hrule -* =pprint-plist= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist= - - docu :: none -\hrule -* =alist-get= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist=, =key= - - docu :: none -\hrule -* =alist-find= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist=, =key= - - docu :: none -\hrule -* =alist-key-exists?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist=, =key= - - docu :: none -\hrule -* =alist-remove!= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist=, =key= - - docu :: none -\hrule -* =alist-set!= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist=, =key=, =value= - - docu :: none -\hrule -* =alist-set-overwrite!= - - - type :: =:lambda= - - arguments :: : - - postitional :: =alist=, =key=, =value= - - docu :: none -\hrule -* =plist-get= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist=, =prop= - - docu :: none -\hrule -* =plist-set!= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist=, =prop=, =value= - - docu :: none -\hrule -* =plist-set-overwrite!= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist=, =prop=, =value= - - docu :: none -\hrule -* =plist-find= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist=, =prop= - - docu :: none -\hrule -* =plist-prop-exists?= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist=, =prop= - - docu :: none -\hrule -* =plist-remove!= - - - type :: =:lambda= - - arguments :: : - - postitional :: =plist=, =prop= - - docu :: none -\hrule -* =cons= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:833:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =car= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:843:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =cdr= - - - defined in :: =d:\code\gitlab\slime\src\./built_ins.cpp:854:0= - - type :: =:cfunction= - - docu :: - #+BEGIN: -TODO - #+END: -\hrule -* =caar= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cddr= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cadr= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cdar= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =caaar= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =caadr= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cadar= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =caddr= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cdaar= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cdadr= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cddar= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =cdddr= - - - type :: =:lambda= - - arguments :: : - - postitional :: =seq= - - docu :: none -\hrule -* =define-class= - - - defined in :: =oo.slime:22:22= - - type :: =:macro= - - arguments :: : - - postitional :: =name-and-members=: - - rest :: =body= - - docu :: - #+BEGIN: -Macro for creating simple classes. - #+END: -\hrule -* =->= - - - defined in :: =oo.slime:25:24= - - type :: =:macro= - - arguments :: : - - postitional :: =obj=, =meth=: - - rest :: =args= - - docu :: none -\hrule -* =math::pi= - - - defined in :: =pre.slime:338:12= - - type :: =:number= - - value :: =3.141593= - - docu :: - #+BEGIN: -Tha famous circle constant. - #+END: -\hrule -* =math::abs= - - - defined in :: =pre.slime:338:12= - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Accepts one argument and returns the absoulte value of it - #+END: -\hrule -* =math::sqrt= - - - defined in :: =pre.slime:338:12= - - type :: =:lambda= - - arguments :: : - - postitional :: =x= - - docu :: - #+BEGIN: -Accepts one argument and returns the square root of it - #+END: -\hrule -* =math::make-vector3= - - - defined in :: =pre.slime:338:12= - - type :: =:constructor= - - arguments :: : - - postitional :: =x=, =y=, =z= - - docu :: - #+BEGIN: -This is the handle to an object of the class vector3 - #+END: +\hrule +* =file_name= + + - defined in :: =generate-docs.slime:5:44= + - type :: =:string= + - value :: ="../manual/built-in-docs.org"= + - docu :: none +\hrule +* === + + - defined in :: =src/./built_ins.cpp:159:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +Takes 0 or more arguments and returns =t= if all arguments are equal and =()= otherwise. + #+END: +\hrule +* =>= + + - defined in :: =src/./built_ins.cpp:175:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =>== + + - defined in :: =src/./built_ins.cpp:189:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =<= + + - defined in :: =src/./built_ins.cpp:203:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =<== + + - defined in :: =src/./built_ins.cpp:217:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =+= + + - defined in :: =src/./built_ins.cpp:231:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =-= + + - defined in :: =src/./built_ins.cpp:243:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =*= + + - defined in :: =src/./built_ins.cpp:264:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =/= + + - defined in :: =src/./built_ins.cpp:281:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =**= + + - defined in :: =src/./built_ins.cpp:300:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =%= + + - defined in :: =src/./built_ins.cpp:307:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =assert= + + - defined in :: =src/./built_ins.cpp:314:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =define-syntax= + + - defined in :: =src/./built_ins.cpp:323:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =define= + + - defined in :: =src/./built_ins.cpp:369:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =mutate= + + - defined in :: =src/./built_ins.cpp:425:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =vector-length= + + - defined in :: =src/./built_ins.cpp:447:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =vector-ref= + + - defined in :: =src/./built_ins.cpp:452:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =vector-set!= + + - defined in :: =src/./built_ins.cpp:465:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =set!= + + - defined in :: =src/./built_ins.cpp:480:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =set-car!= + + - defined in :: =src/./built_ins.cpp:500:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =set-cdr!= + + - defined in :: =src/./built_ins.cpp:508:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =if= + + - defined in :: =src/./built_ins.cpp:516:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =quote= + + - defined in :: =src/./built_ins.cpp:530:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =quasiquote= + + - defined in :: =src/./built_ins.cpp:534:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =and= + + - defined in :: =src/./built_ins.cpp:631:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =or= + + - defined in :: =src/./built_ins.cpp:643:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =not= + + - defined in :: =src/./built_ins.cpp:655:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =lambda= + + - defined in :: =src/./built_ins.cpp:689:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =special-lambda= + + - defined in :: =src/./built_ins.cpp:705:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =eval= + + - defined in :: =src/./built_ins.cpp:721:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =begin= + + - defined in :: =src/./built_ins.cpp:731:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =list= + + - defined in :: =src/./built_ins.cpp:743:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =vector= + + - defined in :: =src/./built_ins.cpp:747:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =pair= + + - defined in :: =src/./built_ins.cpp:754:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =first= + + - defined in :: =src/./built_ins.cpp:761:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =rest= + + - defined in :: =src/./built_ins.cpp:768:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =set-type!= + + - defined in :: =src/./built_ins.cpp:775:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =delete-type!= + + - defined in :: =src/./built_ins.cpp:781:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =type= + + - defined in :: =src/./built_ins.cpp:786:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =mem-reset= + + - defined in :: =src/./built_ins.cpp:819:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =info= + + - defined in :: =src/./built_ins.cpp:828:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =show= + + - defined in :: =src/./built_ins.cpp:899:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =addr-of= + + - defined in :: =src/./built_ins.cpp:911:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =generate-docs= + + - defined in :: =src/./built_ins.cpp:916:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =print= + + - defined in :: =src/./built_ins.cpp:922:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =read= + + - defined in :: =src/./built_ins.cpp:937:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =exit= + + - defined in :: =src/./built_ins.cpp:949:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =break= + + - defined in :: =src/./built_ins.cpp:954:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =memstat= + + - defined in :: =src/./built_ins.cpp:960:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =load= + + - defined in :: =src/./built_ins.cpp:979:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =import= + + - defined in :: =src/./built_ins.cpp:989:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =copy= + + - defined in :: =src/./built_ins.cpp:1000:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =symbol->keyword= + + - defined in :: =src/./built_ins.cpp:1013:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =string->symbol= + + - defined in :: =src/./built_ins.cpp:1018:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =symbol->string= + + - defined in :: =src/./built_ins.cpp:1027:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =concat-strings= + + - defined in :: =src/./built_ins.cpp:1034:0= + - type :: =:cfunction= + - docu :: + #+BEGIN: +TODO + #+END: +\hrule +* =pe= + + - type :: =:macro= + - arguments :: : + - postitional :: =expr= + - docu :: none +\hrule +* =when= + + - type :: =:macro= + - arguments :: : + - postitional :: =condition=: + - rest :: =body= + - docu :: + #+BEGIN: +Special form for when multiple actions should be done if a +condition is true. + +{{{example_start}}} +(when (not ()) + (print "Hello ") + (print "from ") + (print "when!")) + +(when () + (print "Goodbye ") + (print "World!")) +{{{example_end}}} + + #+END: +\hrule +* =unless= + + - type :: =:macro= + - arguments :: : + - postitional :: =condition=: + - rest :: =body= + - docu :: + #+BEGIN: +Special form for when multiple actions should be done if a +condition is false. + #+END: +\hrule +* =n-times= + + - type :: =:macro= + - arguments :: : + - postitional :: =times=, =action= + - docu :: + #+BEGIN: +Executes action times times. + #+END: +\hrule +* =let= + + - type :: =:macro= + - arguments :: : + - postitional :: =bindings=: + - rest :: =body= + - docu :: none +\hrule +* =cond= + + - type :: =:macro= + - arguments :: : + - rest :: =clauses= + - docu :: none +\hrule +* =case= + + - type :: =:macro= + - arguments :: : + - postitional :: =var=: + - rest :: =clauses= + - docu :: none +\hrule +* =define-special= + + - type :: =:macro= + - arguments :: : + - postitional :: =name-and-args=: + - rest :: =body= + - docu :: none +\hrule +* =construct-list= + + - type :: =:macro= + - arguments :: : + - rest :: =body= + - docu :: + #+BEGIN: + +{{{example_start}}} +(construct-list + i <- '(1 2 3 4 5) + yield (* i i)) +{{{example_end}}} + +(construct-list + i <- '(1 2 3 4) + j <- '(A B) + yield (pair i j)) + +(construct-list + i <- '(1 2 3 4 5 6 7 8) + if (= 0 (% i 2)) + yield i) + + #+END: +\hrule +* =apply= + + - type :: =:macro= + - arguments :: : + - postitional :: =fun=, =seq= + - docu :: + #+BEGIN: +Applies the function to the sequence, as in calls the function with +ithe sequence as arguemens. + #+END: +\hrule +* =define-typed= + + - type :: =:macro= + - arguments :: : + - postitional :: =args=: + - rest :: =body= + - docu :: none +\hrule +* =define-module= + + - type :: =:macro= + - arguments :: : + - postitional :: =module-name=: + - keyword :: =exports=: + - rest :: =body= + - docu :: none +\hrule +* =null?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is =nil=. + #+END: +\hrule +* =type=?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =obj=, =typ= + - docu :: + #+BEGIN: +Checks if the argument =obj= is of type =typ= + #+END: +\hrule +* =types=?= + + - type :: =:lambda= + - arguments :: : + - rest :: =objs= + - docu :: none +\hrule +* =assert-types== + + - type :: =:lambda= + - arguments :: : + - rest :: =objs= + - docu :: none +\hrule +* =number?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a number. + #+END: +\hrule +* =symbol?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a symbol. + #+END: +\hrule +* =keyword?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a keyword. + #+END: +\hrule +* =pair?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a pair. + #+END: +\hrule +* =string?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a string. + #+END: +\hrule +* =lambda?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a function. + #+END: +\hrule +* =macro?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a macro. + #+END: +\hrule +* =special-lambda?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a special-lambda. + #+END: +\hrule +* =built-in-function?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a built-in function. + #+END: +\hrule +* =callable?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =x= + - docu :: none +\hrule +* =end= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq= + - docu :: + #+BEGIN: +Returns the last pair in the sqeuence. + +{{{example_start}}} +(define a (list 1 2 3 4)) +(print (end a)) +{{{example_end}}} + + #+END: +\hrule +* =last= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq= + - docu :: + #+BEGIN: +Returns the (first) of the last (pair) of the given sequence. + +{{{example_start}}} +(define a (list 1 2 3 4)) +(print (last a)) +{{{example_end}}} + + #+END: +\hrule +* =extend= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq=, =elem= + - docu :: + #+BEGIN: +Extends a list with the given element, by putting it in +the (rest) of the last element of the sequence. + #+END: +\hrule +* =extend2= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq=, =elem= + - docu :: + #+BEGIN: +Extends a list with the given element, by putting it in +the (rest) of the last element of the sequence. + #+END: +\hrule +* =append= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq=, =elem= + - docu :: + #+BEGIN: +Appends an element to a sequence, by extendeing the list +with (pair elem nil). + #+END: +\hrule +* =length= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq= + - docu :: + #+BEGIN: +Returns the length of the given sequence. + #+END: +\hrule +* =member?= + + - type :: =:lambda= + - arguments :: : + - postitional :: =elem=, =seq= + - docu :: none +\hrule +* =sublist-starting-at-index= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq=, =index= + - docu :: none +\hrule +* =list-without-index= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq=, =index= + - docu :: none +\hrule +* =increment= + + - type :: =:lambda= + - arguments :: : + - postitional :: =val= + - docu :: + #+BEGIN: +Adds one to the argument. + #+END: +\hrule +* =decrement= + + - type :: =:lambda= + - arguments :: : + - postitional :: =val= + - docu :: + #+BEGIN: +Subtracts one from the argument. + #+END: +\hrule +* =range= + + - type :: =:lambda= + - arguments :: : + - keyword :: =from= =(0)=, =to= + - docu :: + #+BEGIN: +Returns a sequence of numbers starting with the number defined +by the key =from= and ends with the number defined in =to=. + #+END: +\hrule +* =range-while= + + - type :: =:lambda= + - arguments :: : + - keyword :: =from= =(0)= + - docu :: + #+BEGIN: +Returns a sequence of numbers starting with the number defined +by the key 'from' and ends with the number defined in 'to'. + #+END: +\hrule +* =map= + + - type :: =:lambda= + - arguments :: : + - postitional :: =fun=, =seq= + - docu :: + #+BEGIN: +Takes a function and a sequence as arguments and returns a new +sequence which contains the results of using the first sequences +elemens as argument to that function. + #+END: +\hrule +* =reduce= + + - type :: =:lambda= + - arguments :: : + - postitional :: =fun=, =seq= + - docu :: + #+BEGIN: +Takes a function and a sequence as arguments and applies the +function to the argument sequence. This only works correctly if the +given function accepts a variable amount of parameters. If your +funciton is limited to two arguments, use [[=reduce-binary=]] +instead. + #+END: +\hrule +* =reduce-binary= + + - type :: =:lambda= + - arguments :: : + - postitional :: =fun=, =seq= + - docu :: + #+BEGIN: +Takes a function and a sequence as arguments and applies the +function to the argument sequence. reduce-binary applies the arguments +*pair-wise* which means it works with binary functions as compared to +[[=reduce=]]. + #+END: +\hrule +* =filter= + + - type :: =:lambda= + - arguments :: : + - postitional :: =fun=, =seq= + - docu :: + #+BEGIN: +Takes a function and a sequence as arguments and applies the +function to every value in the sequence. If the result of that +funciton application returns a truthy value, the original value is +added to a list, which in the end is returned. + #+END: +\hrule +* =zip= + + - type :: =:lambda= + - arguments :: : + - postitional :: =l1=, =l2= + - docu :: none +\hrule +* =unzip= + + - type :: =:lambda= + - arguments :: : + - postitional :: =lists= + - docu :: none +\hrule +* =enumerate= + + - type :: =:lambda= + - arguments :: : + - postitional :: =seq= + - docu :: none diff --git a/src/built_ins.cpp b/src/built_ins.cpp index a1d8964..fbb4461 100644 --- a/src/built_ins.cpp +++ b/src/built_ins.cpp @@ -1,5 +1,5 @@ inline proc maybe_wrap_body_in_begin(Lisp_Object* body) -> Lisp_Object* { - static Lisp_Object* begin_symbol = Memory::get_or_create_lisp_object_symbol("begin"); + Lisp_Object* begin_symbol = Memory::get_or_create_lisp_object_symbol("begin"); if (body->value.pair.rest == Memory::nil) return body->value.pair.first; else @@ -101,11 +101,11 @@ proc built_in_import(String* file_name) -> Lisp_Object* { } proc load_built_ins_into_environment() -> void { - static String* file_name_built_ins = Memory::create_string(__FILE__); + String* file_name_built_ins = Memory::create_string(__FILE__); #define fetch1(var) \ - static Lisp_Object* var##_symbol = Memory::get_or_create_lisp_object_symbol(#var); \ + Lisp_Object* var##_symbol = Memory::get_or_create_lisp_object_symbol(#var); \ Lisp_Object* var = lookup_symbol(var##_symbol, get_current_environment()); \ if (Globals::error) printf("in %s:%d\n", __FILE__, __LINE__) @@ -128,12 +128,12 @@ proc load_built_ins_into_environment() -> void { // parser relys on being able to temporaily put in markers // in the code #define _define_helper(def, docs, special) \ - static Lisp_Object* label(params,__LINE__) = Parser::parse_single_expression( \ + auto label(params,__LINE__) = Parser::parse_single_expression( \ Memory::get_c_str(Memory::create_string(#def)) \ ); \ assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \ assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \ - static auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \ + auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \ auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \ /*NOTE(Felix): for evaluating default args*/ \ push_environment(get_root_environment()); \ @@ -481,13 +481,13 @@ proc load_built_ins_into_environment() -> void { fetch(sym, val); try assert_type(sym, Lisp_Object_Type::Symbol); - + Environment* target_env; in_caller_env { val = eval_expr(val); + target_env = find_binding_environment(sym->value.symbol.identifier, get_current_environment()); + try assert(target_env); } - Environment* target_env = find_binding_environment(sym->value.symbol.identifier, get_current_environment()); - try assert(target_env); push_environment(target_env); { @@ -728,13 +728,14 @@ proc load_built_ins_into_environment() -> void { return result; }; - define((begin . args), "TODO") { + define_special((begin . args), "TODO") { fetch(args); Lisp_Object* result = Memory::nil; - for_lisp_list(args) { - try result = eval_expr(it); + in_caller_env { + for_lisp_list(args) { + try result = eval_expr(it); + } } - return result; }; define((list . args), "TODO") { @@ -813,6 +814,10 @@ proc load_built_ins_into_environment() -> void { } return Memory::get_or_create_lisp_object_keyword("unknown"); }; + define((mem-reset), "TODO") { + Memory::reset(); + return Memory::nil; + }; // NOTE(Felix): we need to define_special because the docstring is // attached to the symbol. Because some object are singletons // (symbols, keyowrds, nil, t) we dont want to store docs on the @@ -887,20 +892,6 @@ proc load_built_ins_into_environment() -> void { printf("}\n"); } - // } - // // TODO(Felix): Maybe don't compare strings here?? Wtf - // if (Memory::get_type(type) == Lisp_Object_Type::Keyword && - // (string_equal(type->value.symbol.identifier, "lambda") || - // string_equal(type->value.symbol.identifier, "special-lambda") || - // string_equal(type->value.symbol.identifier, "macro"))) - // { - // Lisp_Object* fun = eval_expr(n); - - // if (fun->docstring) - // printf("Docstring:\n==========\n%s\n\n", Memory::get_c_str(fun->docstring)); - // else - // printf("No docstring avaliable\n"); - return Memory::nil; }; define((show n), "TODO") { @@ -968,21 +959,20 @@ proc load_built_ins_into_environment() -> void { Memory::print_status(); return Memory::nil; }; - // // defun("try", "TODO", __LINE__, cLambda { - // // try arguments_length = list_length(arguments); - // // try assert_arguments_length(2, arguments_length); + define_special((mytry try_part catch_part), "TODO") { + fetch(try_part, catch_part); - // // Lisp_Object* try_part = arguments->value.pair.first; - // // Lisp_Object* catch_part = arguments->value.pair.rest->value.pair.first; - // // Lisp_Object* result; + Lisp_Object* result; - // // result = eval_expr(try_part); - // // if (Globals::error) { - // // delete_error(); - // // try result = eval_expr(catch_part); - // // } - // // return result; - // // }); + in_caller_env { + result = eval_expr(try_part); + if (Globals::error) { + delete_error(); + try result = eval_expr(catch_part); + } + } + return result; + }; define((load file), "TODO") { fetch(file); try assert_type(file, Lisp_Object_Type::String); diff --git a/src/env.cpp b/src/env.cpp index 16b6941..0e673de 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -84,7 +84,9 @@ inline proc get_current_environment() -> Environment* { } proc lookup_symbol(Lisp_Object* node, Environment* env) -> Lisp_Object* { - assert_type(node, Lisp_Object_Type::Symbol); + // print(node); + // printf("\n"); + assert_type(node, Lisp_Object_Type::Symbol); Lisp_Object* result = try_lookup_symbol(node, env); diff --git a/src/error.cpp b/src/error.cpp index 124c63e..4b54fed 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -16,7 +16,7 @@ proc create_error(const char* c_file_name, int c_file_line, Lisp_Object* type, S delete_error(); if (Globals::breaking_on_errors) { - debug_break(); + // debug_break(); } // visualize_lisp_machine(); diff --git a/src/eval.cpp b/src/eval.cpp index a0ab2f9..03fc33d 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -321,6 +321,7 @@ proc create_arguments_from_lambda_list_and_inject(Lisp_Object* arguments, Lisp_O create_parsing_error("Default args must be a list of 2."); } auto value = arguments->value.pair.first->value.pair.rest->value.pair.first; + value = eval_expr(value); if (arguments->value.pair.first->value.pair.rest->value.pair.rest != Memory::nil) { create_parsing_error("Default args must be a list of 2."); } diff --git a/src/main.cpp b/src/main.cpp index 7de470a..9d85852 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,7 @@ int main(int argc, char* argv[]) { if (argc > 1) { if (Slime::string_equal(argv[1], "--run-tests")) { int res = Slime::run_all_tests(); - Slime::interprete_file((char*)"generate-docs.slime"); + // Slime::interprete_file((char*)"generate-docs.slime"); return res ? 0 : 1; }